Android:发布 APK 上的 java.lang.NoClassDefFoundError

标签 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:发布 APK 上的 java.lang.NoClassDefFoundError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36547087/

相关文章:

android - 如何读取当前权限状态?

java - 更改窗口标题背景样式

java - Android Java 特定音乐文件夹

java - 如何在 src 的 imageView 中设置正确的方向

java - 弹出菜单没有膨胀

java - 在 Android 上回收膨胀 View

android - 我的应用程序没有出现在市场上

java - Android:如何使用JobService的JobFinished

android - 无法使用其最新版本为 Android 构建 Cordova 项目

android - 打算在 fragment 类中