1

I am getting an error when building APK with Android Studio. My project requires multi-dexing, and I have enabled it in my build.gradle. I also ensures that the build tools in the build.gradle file is up to date (currently using version 2.2.3)

dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'
}

However, even though I have clean/rebuild the project, or "Invalidate Caches/Restart", there is constantly an error occurring.

Upon building, the error pops out:

Error:Execution failed for task ':app:transformClassesWithMultidexlistForDevDebug'.
> java.util.NoSuchElementException (no error message)

The above error occurs when "Instant Run" is disabled. If I enable it, the apk could be successfully installed, yet there is another exception:

Caused by: java.lang.ClassNotFoundException: Didn't find class "com.a.b.c.ABCApplication" on path: DexPathList[[zip file "/data/app/com.a.b.c.dev-1/base.apk"],nativeLibraryDirectories=[/data/app/com.a.b.c.dev-1/lib/x86, /vendor/lib, /system/lib]]

I also tried to add the following lines in the build.gradle

dexOptions {
    preDexLibraries true
    javaMaxHeapSize "4g"
    dexInProcess false
}

I also tried to disable "Instance Run" in the preference, still in vain.

Anyone could help?

I confirmed that this error is not due to changes made it the recent update of my project, since this occurs even though I roll back my project to one or two weeks ago. Yet wierd enough, the error did not occur last week. I wonder if it is due to gradle's update?

MungoRae
  • 1,912
  • 1
  • 16
  • 25
Derekyy
  • 1,018
  • 4
  • 18
  • 31
  • Hello check this answer it may help you. http://stackoverflow.com/a/37179073/1140237 specifically gradle http://stackoverflow.com/a/34650143/1140237 – user1140237 Jan 03 '17 at 08:19
  • I read the SO post, yet I still cannot find my answer there, That post mainly ask me to enable multi-dex in build.gradle or in the Application in run-time, which I already did. – Derekyy Jan 03 '17 at 08:28

1 Answers1

1

At last it is found that it is due to an update of another third-party library.

In build.gradle, the original culprit is

    classpath 'com.appdynamics:appdynamics-gradle-plugin:4.+'

After changing it to

    classpath 'com.appdynamics:appdynamics-gradle-plugin:4.2.9.0'

everything works fine :)

Derekyy
  • 1,018
  • 4
  • 18
  • 31