Android 应用程序在低于 5.0.1 的版本上崩溃 - 类 未找到库

Android app crashing on version below 5.0.1 - classes are not being found for libraries

我在我的 Android 应用程序中使用 SweetAlert 库和 RippleView 库。

该应用程序在 Android v5.0.2 的设备上运行完美,但在 Android v4.4.2 及更低版本的多台设备上崩溃,但以下情况除外:

java.lang.RuntimeException: Unknown animation name: cn.pedant.SweetAlert.Rotate3dAnimation error:cn.pedant.SweetAlert.Rotate3dAnimation

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.sample/com.sample.RegistrationActivity_}: android.view.InflateException: Binary XML file line #44: Error inflating class com.andexert.library.RippleView

我认为这可能与混淆器有关,那些 类 不可见,但即使在禁用混淆器后,崩溃仍在继续。

这是我的 build.gradle:

    apply plugin: 'com.android.application'
    apply plugin: 'android-apt'
    def AAVersion = '3.2'

    buildscript {
        repositories {
            mavenCentral()
        }

        dependencies {
            classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
        }
    }

    apt {
        arguments {
            androidManifestFile variant.outputs[0].processResources.manifestFile
            resourcePackageName 'com.sample'
        }
    }

    android {
        compileSdkVersion 21
        buildToolsVersion "21.1.2"

        defaultConfig {
            applicationId "com.sample"
            minSdkVersion 14
            targetSdkVersion 21
            versionCode 1
            versionName "1.0"
            multiDexEnabled = true
        }
        buildTypes {
            release {
                minifyEnabled false
    //            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }

    dependencies {
        compile fileTree(include: ['*.jar'], dir: 'libs')
        apt "org.androidannotations:androidannotations:$AAVersion"
        compile "org.androidannotations:androidannotations-api:$AAVersion"
        compile project(':intercom-sdk-0.9.5')
        compile 'de.greenrobot:eventbus:2.4.0'
        compile 'com.android.support:appcompat-v7:21.0.3'
        compile 'com.edmodo:cropper:1.0.1'
        compile 'com.mobsandgeeks:android-saripaar:1.0.3'
        compile 'cn.pedant.sweetalert:library:1.3'
        compile 'com.github.navasmdc:MaterialDesign:1.+@aar'
        compile 'com.nineoldandroids:library:2.4.0'
        compile 'it.sephiroth.android.library.horizontallistview:hlistview:1.2.2'
        compile 'com.jpardogo.materialtabstrip:library:1.0.9'
        compile 'com.koushikdutta.ion:ion:2.+'
        compile 'com.facebook.android:facebook-android-sdk:3.21.1'
    //    compile 'com.google.android.gms:play-services:6.5.87'
        compile 'org.apmem.tools:layouts:1.8@aar'
        compile 'com.github.traex.rippleeffect:library:1.2.4'
        compile 'com.snappydb:snappydb-lib:0.5.0'
        compile 'com.esotericsoftware.kryo:kryo:2.24.0'
        compile 'com.rockerhieu.emojicon:library:1.0'
        compile 'com.android.support:support-v4:22.0.+'
        compile 'com.google.code.gson:gson:2.3'
        compile 'com.squareup:otto:1.3.6'
        compile 'com.squareup.okhttp:okhttp:2.3.0'
        compile 'com.squareup.retrofit:retrofit:1.9.0'
        compile 'com.squareup.picasso:picasso:2.5.2'
        compile 'com.google.android.gms:play-services:7.0.0'
        compile 'com.facebook.fresco:fresco:0.1.0+'
        compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.3'
    }

堆栈跟踪:

java.lang.RuntimeException: Unknown animation name: cn.pedant.SweetAlert.Rotate3dAnimation error:cn.pedant.SweetAlert.Rotate3dAnimation at cn.pedant.SweetAlert.OptAnimationLoader.createAnimationFromXml(OptAnimationLoader.java:77) at cn.pedant.SweetAlert.OptAnimationLoader.createAnimationFromXml(OptAnimationLoader.java:64) at cn.pedant.SweetAlert.OptAnimationLoader.createAnimationFromXml(OptAnimationLoader.java:41) at cn.pedant.SweetAlert.OptAnimationLoader.loadAnimation(OptAnimationLoader.java:22) at cn.pedant.SweetAlert.SweetAlertDialog.(SweetAlertDialog.java:80) at com.sample.SampleActivity.loginWithFacebook(JoinNeighbourhoodActivity.java:232) at com.sample.SampleActivity.processFacebookUser(JoinNeighbourhoodActivity.java:187) at com.sample.SampleActivity.access[=15=]0(JoinNeighbourhoodActivity.java:48) at com.sample.SampleActivity.onCompleted(JoinNeighbourhoodActivity.java:138) at com.facebook.Request.onCompleted(Request.java:281) at com.facebook.Request.run(Request.java:1666) at android.os.Handler.handleCallback(Handler.java:733) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:157) at android.app.ActivityThread.main(ActivityThread.java:5356) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081) at dalvik.system.NativeStart.main(Native Method)

有同样的问题。我通过将其添加到我的应用程序 class

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

问题是由于超过了函数计数限制。 必须将应用程序转换为 multi-dex。