I have the following exception when launching my ap on API 22 and below (works very well on API 24, the target and compile API).
10-06 10:08:57.919 5014-5014/? E/UncaughtException: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/ads/conversiontracking/AdWordsConversionReporter;
at com.myapp.androidapp.ui.splash.SplashActivity.onResume(SplashActivity.java:57)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1241)
at android.app.Activity.performResume(Activity.java:6019)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2940)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2982)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2365)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.ads.conversiontracking.AdWordsConversionReporter" on path: DexPathList[[zip file "/data/app/com.myapp.androidapp.preprod.debug-2/base.apk"],nativeLibraryDirectories=[/data/app/com.myapp.androidapp.preprod.debug-2/lib/arm, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at com.myapp.androidapp.ui.splash.SplashActivity.onResume(SplashActivity.java:57)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1241)
at android.app.Activity.performResume(Activity.java:6019)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2940)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2982)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2365)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Suppressed: java.lang.ClassNotFoundException: com.google.ads.conversiontracking.AdWordsConversionReporter
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 16 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
It moves on another class if I comment the line where I use AdWordsConversionReporter (it can be library class or custom class).
Seems to be related with Multidexing but I'm pretty sure I'm using it well. In my gradle I have this following lines :
multiDexEnabled true
and
compile('com.android.support:multidex:1.0.1') {
exclude group: 'com.android.support'
}
Here is a part of my application class:
public class MyApplication extends MultiDexApplication {
..
}
And a part of my manifest :
<application
android:name=".ui.MyApplication"
android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="@mipmap/icon"
android:label="@string/app_name"
android:theme="@style/AppTheme"
tools:replace="android:theme">
I tried a lot of solution found here on a lot of questions looking similar like adding MultiDex.install(this) on my Application class, clean my project, re-sync Gradle, enable minify on my gradle (and a lot more) but nothing works. Any solution to resolve it ?
Works by adding
preDexLibraries false
to my gradle.