在API 22及更低版本上启动我的ap时出现以下异常(在API 24,目标和编译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
如果我评论使用AdWordsConversionReporter的行(它可以是库类或自定义类),它会移动到另一个类。
似乎与Multidexing有关,但我很确定我使用它很好。 在我的gradle中,我有以下几行:
multiDexEnabled true
和
compile('com.android.support:multidex:1.0.1') {
exclude group: 'com.android.support'
}
以下是我的应用程序类的一部分:
public class MyApplication extends MultiDexApplication {
..
}
我的清单的一部分:
<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">
我在很多问题上尝试了很多解决方案看起来类似于在我的Application类上添加MultiDex.install(this),清理我的项目,重新同步Gradle,在我的gradle上启用minify(以及更多)但没有任何作用。 解决它的任何解决方案?
答案 0 :(得分:0)
通过添加
工作preDexLibraries false
到我的gradle。