Search code examples
androidandroid-gradle-pluginproguardandroid-5.0-lollipopclassnotfoundexception

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


I am using SweetAlert library and RippleView libraries in my Android app.

The app runs perfectly fine on a device with Android v5.0.2 but crashes on multiple devices with Android v4.4.2 and below, with the following exceptions:

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

AND

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

I thought this might be related to proguard that those classes are not visible, but even after disabling ProGuard, the crashes continue.

Here is my 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'
    }

Stacktrace:

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$000(JoinNeighbourhoodActivity.java:48) at com.sample.SampleActivity$1$1.onCompleted(JoinNeighbourhoodActivity.java:138) at com.facebook.Request$1.onCompleted(Request.java:281) at com.facebook.Request$4.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)


Solution

  • Had the same problem. I fixed it by adding this to my Application class

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