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?
At last it is found that it is due to an update of another third-party library.
In build.gradle, the original culprit is
After changing it to
everything works fine :)