0

JDK 1.8

IDEA CE version 2017.1

Mac OSX 10.12.6

Android API 22, 24, 26

When building PhoneGap app for android (maven build tool), the app crashes with the following console output. I don't understand java debug output and I haven't found any resolution here or anywhere else for that matter. I think it's a bug with the tool. I can run the app with no problems when launched through Google Chrome.

Error:Android Pre Dex: [cordova-2.3.0.jar] Failed to load dx.jar
Error:Android Pre Dex: [cordova-2.3.0.jar] java.lang.ClassNotFoundException: com.android.dx.command.DxConsole
Error:Android Pre Dex: [cordova-2.3.0.jar] at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
Error:Android Pre Dex: [cordova-2.3.0.jar] at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
Error:Android Pre Dex: [cordova-2.3.0.jar] at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
Error:Android Pre Dex: [cordova-2.3.0.jar] at org.jetbrains.android.compiler.tools.AndroidDxRunner.loadDex(AndroidDxRunner.java:80)
Error:Android Pre Dex: [cordova-2.3.0.jar] at org.jetbrains.android.compiler.tools.AndroidDxRunner.runDex(AndroidDxRunner.java:136)
Error:Android Pre Dex: [cordova-2.3.0.jar] at org.jetbrains.android.compiler.tools.AndroidDxRunner.main(AndroidDxRunner.java:336)
Error:Android Pre Dex: [cordova-2.3.0.jar] Exception in thread "main" java.lang.NullPointerException
Error:Android Pre Dex: [cordova-2.3.0.jar] at org.jetbrains.android.compiler.tools.AndroidDxRunner.runDex(AndroidDxRunner.java:139)

For reference: JetBrains bug report

Mike S.
  • 1,476
  • 1
  • 24
  • 42
  • https://stackoverflow.com/questions/5228453/android-adt-error-dx-jar-was-not-loaded-from-the-sdk-folder Try the accepted answer here and see if you're simply missing dx.jar – drelliot Aug 02 '17 at 23:48

1 Answers1

2

I had a similar problem. Try to remove newest SDK build tools(In SDK Manager). After that reset IDE - it helped in my case.

Unii
  • 1,446
  • 14
  • 30
  • I faced similar issue with eclipse ADT, not with phonegap. This solution works as per https://www.buildbox.com/forum/index.php?threads/unable-to-build-the-file-dx-jar-was-not-loaded-from-the-sdk-folder.10821/ But, is it possible to have the latest SDK build tools, and get it working? E.g: in Android Studio, build.gradle, it is possible to specify buildToolsVersion. But, I am not aware of a similar setting in case of Ant build system. I tried to rename the latest build tools with _ appended at the beginning hoping that build will pick the old build tools (25.0.2). But, it did not work. – garnet Dec 15 '17 at 15:06
  • I think it's not possible. So, I ended up maintaining two sdk locations: one for eclipse and another for studio. – garnet Dec 17 '17 at 15:59