Android: NoClassDefFoundError only on release build

后端 未结 2 1535
广开言路
广开言路 2021-01-25 19:11

I\'m on Android Studio and trying to build my project on release mode.
Everything is OK in debug mode however below errors occur in release mode...



        
2条回答
  •  终归单人心
    2021-01-25 19:55

    The problem is basically the following:

    buildTypes {
            release {
                **minifyEnabled false**
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    

    If you set minifyEnabled to false, it should fix your problem. If you want to use the minify feature then you can add progaurd rules to your build.gradle. For instance for the Butterknife library you have to add the following:

    -keep class butterknife.** { *; }
    -dontwarn butterknife.internal.**
    -keep class **$$ViewBinder { *; }
    
    -keepclasseswithmembernames class * {
        @butterknife.* ;
    }
    
    -keepclasseswithmembernames class * {
        @butterknife.* ;
    }
    

    Glad I could help

提交回复
热议问题