设置MinifyEnabled true后Android apk崩溃

时间:2016-08-06 09:42:15

标签: android android-studio android-proguard

当我按照设备监视器时收到以下错误:

Binary XML file line #17: Error inflating class android.support.design.internal.NavigationMenuView

如果我将minifyEnabled设置为false并使用zipalign + redex发布apk一切正常。

我尝试过清理和重建项目,还尝试在proguard文件中添加以下行:

-dontwarn android.support.design.**
-keep class android.support.design.** { *; }
-keep interface android.support.design.** { *; }
-keep public class android.support.design.R$* { *; 

build.gradle文件:

    apply plugin: 'com.android.application'

    android {
    compileSdkVersion 24
    buildToolsVersion "24.0.1"
    defaultConfig {
        applicationId "com.evinsahibi"
        minSdkVersion 21
        targetSdkVersion 24
        versionCode 3
        versionName "3.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        jackOptions {
            enabled true
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
     androidTestCompile('com.android.support.test.espresso:espresso-           core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:24.1.1'
    compile 'com.google.android.gms:play-services-base:9.4.0'
    compile 'com.google.android.gms:play-services-maps:9.4.0'
    compile 'com.android.support:design:24.1.1'
    compile 'com.android.support:cardview-v7:24.1.1'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'com.squareup.retrofit2:retrofit:2.1.0'
    compile 'com.squareup.retrofit2:converter-gson:2.1.0'
    compile 'com.google.android.gms:play-services-appindexing:9.4.0'
    compile 'com.android.support:support-v4:24.1.1'
    testCompile 'junit:junit:4.12'
    compile 'com.jakewharton:butterknife:8.1.0'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.1.0'
   }

0 个答案:

没有答案