Android: java.lang.NoClassDefFoundError on the release APK

标签 android

我构建了我的应用程序的发布 APK。它在很多设备上都是完美的;但在此设备上 (Google Nexus 5 - 4.4.4 - API 19) 出现崩溃:

Fatal Exception: java.lang.NoClassDefFoundError: org.joda.time.format.ISODateTimeFormat$Constants
       at org.joda.time.format.ISODateTimeFormat.dateTimeNoMillis(ISODateTimeFormat.java:789)
       at com.azeoo.android.network.converter.DateTimeConverter.deserializeDateTime(DateTimeConverter.java:84)
       at com.azeoo.android.network.converter.DateTimeConverter.deserialize(DateTimeConverter.java:70)
       at com.azeoo.android.network.converter.DateTimeConverter.deserialize(DateTimeConverter.java:24)
...

Gradle 文件中正确添加了这个库:

compile 'joda-time:joda-time:2.9.2'

我的 Proguard 文件:

# Specific for https://github.com/PhilJay/MPAndroidChart
-keep class com.github.mikephil.charting.** { *; }

# Specific for https://github.com/bumptech/glide
-keep public class * implements com.bumptech.glide.module.GlideModule
-keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** {
    **[] $VALUES;
    public *;
}

# Esperandro
# Specific for http://dkunzler.github.io/esperandro/
-keepnames class de.devland.** { *; }
-keep class **$$Impl { public *;}

# keep the annotated things annotated
-keepattributes *Annotation*, EnclosingMethod, Signature, InnerClasses

# for dagger also preserve the interfaces
# assuming they reside in the sub-package 'preferences_main' and all end with 'Prefs'
#-keep class preferences_main.**Prefs { public *;}

# for gson see their documentation at
# https://code.google.com/p/google-gson/source/browse/trunk/examples/android-proguard-example/proguard.cfg

# Butterknife
# http://jakewharton.github.io/butterknife/
-keep class butterknife.** { *; }
-dontwarn butterknife.internal.**
-keep class **$$ViewInjector { *; }

-keepclasseswithmembernames class * {
    @butterknife.* <fields>;
}

-keepclasseswithmembernames class * {
    @butterknife.* <methods>;
}

# Remove Android logging calls
# @see http://stackoverflow.com/questions/15571520/how-to-configure-proguard-to-only-remove-android-logging-calls
# This will not remove error log
-assumenosideeffects class com.azeoo.android.util.LogUtils {
    public static void LOGD(...);
    public static void LOGV(...);
    public static void LOGI(...);
    public static void LOGW(...);
    public static void LOGE(...);
}

你们能帮帮我吗?

最佳答案

我认为它与您所说的 MultiDex 有关,因为它可以在其他设备上运行,但在 KitKat 上却很吃力。将以下内容添加到您的应用程序类:

@Override
protected void attachBaseContext(Context base) {
    super.attachBaseContext(base);
    MultiDex.install(this);
}

关于Android: java.lang.NoClassDefFoundError on the release APK,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36547087/

相关文章:

java - 如何使线始终穿过点?

javascript - 单击在 WebView 中不起作用

android - 获取android中动态 ListView 的行ID以添加到购物车

java - 将数据添加到 firebase

android - 如何在 Android 上访问 USB 设备文件?

android - 在Activity B页面显示Activity A数据

Android 在系统内存不足时杀死广播接收器

Android - 使 AlertDIalog 按钮大小统一

Android - 一个应用程序中有两个或多个 GCM token

java - 在 Parse Android 的一次调用中获取多个对象