签名APK

时间:2018-02-09 10:04:42

标签: android android-studio gradle apk android-proguard

我遇到了这个麻烦,因为它只发生在我使用签名的apk时。我搜索了另一篇文章中的任何解决方案,包括this

这是我的build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion '26.0.2'
    defaultConfig {
        applicationId "com.example.user.matelacc"
        minSdkVersion 17
        targetSdkVersion 26
        versionCode 1
        versionName "1.7"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
    }

    lintOptions {
        checkReleaseBuilds false
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile files('libs/activation.jar')
    compile files('libs/additionnal.jar')
    compile files('libs/mail.jar')
    compile 'com.google.android.gms:play-services-places:11.8.0'
    compile 'com.android.support:appcompat-v7:26.1.0'
    compile 'com.android.support:design:26.1.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.google.android.gms:play-services-maps:11.8.0'
    compile 'com.google.android.gms:play-services-fitness:11.8.0'
    compile 'com.google.android.gms:play-services-wearable:11.8.0'
    compile 'com.google.android.gms:play-services-location:11.8.0'
    compile 'com.google.android.gms:play-services-identity:11.8.0'
    compile 'com.squareup.okhttp3:okhttp:3.7.0'
    compile 'com.mcxiaoke.volley:library:1.0.19'
    testCompile 'junit:junit:4.12'
}

当我将minifyEnabled设置为false时,它会在签名的apk中顺利运行,但是当我将其设置为true时,它会显示错误导致类android.support.design.widget.NavigationView

我有几个问题, 1.为什么会这样? 2.如何解决?

任何帮助都会有所帮助。提前谢谢。

错误

02-12 08:32:53.607 22228-22228/? E/AndroidRuntime: FATAL EXCEPTION: main
                                                   Process: com.example.user.matelacc, PID: 22228
                                                   java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.user.matelacc/com.example.user.matelacc.MenuActivity}: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class android.support.design.widget.NavigationView
                                                       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2984)
                                                       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3045)
                                                       at android.app.ActivityThread.-wrap14(ActivityThread.java)
                                                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1642)
                                                       at android.os.Handler.dispatchMessage(Handler.java:102)
                                                       at android.os.Looper.loop(Looper.java:154)
                                                       at android.app.ActivityThread.main(ActivityThread.java:6776)
                                                       at java.lang.reflect.Method.invoke(Native Method)
                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496)
                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386)
                                                    Caused by: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class android.support.design.widget.NavigationView
                                                    Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class android.support.design.widget.NavigationView
                                                    Caused by: java.lang.reflect.InvocationTargetException
                                                       at java.lang.reflect.Constructor.newInstance0(Native Method)
                                                       at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
                                                       at android.view.LayoutInflater.createView(LayoutInflater.java:652)
                                                       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:794)
                                                       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:734)
                                                       at android.view.LayoutInflater.rInflate(LayoutInflater.java:865)
                                                       at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:828)
                                                       at android.view.LayoutInflater.inflate(LayoutInflater.java:525)
                                                       at android.view.LayoutInflater.inflate(LayoutInflater.java:427)
                                                       at android.view.LayoutInflater.inflate(LayoutInflater.java:378)
                                                       at android.support.v7.app.ap.b(Unknown Source)
                                                       at android.support.v7.app.z.setContentView(Unknown Source)
                                                       at com.example.user.matelacc.MenuActivity.onCreate(Unknown Source)
                                                       at android.app.Activity.performCreate(Activity.java:6955)
                                                       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126)
                                                       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2927)
                                                       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3045)
                                                       at android.app.ActivityThread.-wrap14(ActivityThread.java)
                                                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1642)
                                                       at android.os.Handler.dispatchMessage(Handler.java:102)
                                                       at android.os.Looper.loop(Looper.java:154)
                                                       at android.app.ActivityThread.main(ActivityThread.java:6776)
                                                       at java.lang.reflect.Method.invoke(Native Method)
                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496)
                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386)
                                                    Caused by: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class ImageView
                                                    Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class ImageView
                                                    Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.widget.av.d()' on a null object reference
                                                       at android.support.v7.widget.aw.setImageDrawable(Unknown Source)
                                                       at android.widget.ImageView.<init>(ImageView.java:159)
                                                       at android.widget.ImageView.<init>(ImageView.java:145)
                                                       at android.support.v7.widget.aw.<init>(Unknown Source)
                                                       at android.support.v7.widget.aw.<init>(Unknown Source)
                                                       at android.support.v7.app.be.a(Unknown Source)
                                                       at android.support.v7.app.ap.onCreateView(Unknown Source)
                                                       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776)
                                                       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:734)
                                                       at android.view.LayoutInflater.rInflate(LayoutInflater.java:865)
02-12 08:32:53.607 22228-22228/? E/AndroidRuntime:     at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:828)
                                                       at android.view.LayoutInflater.rInflate(LayoutInflater.java:873)
                                                       at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:828)
                                                       at android.view.LayoutInflater.inflate(LayoutInflater.java:525)
                                                       at android.view.LayoutInflater.inflate(LayoutInflater.java:427)
                                                       at android.support.design.internal.d.b(Unknown Source)
                                                       at android.support.design.widget.NavigationView.<init>(Unknown Source)
                                                       at android.support.design.widget.NavigationView.<init>(Unknown Source)
                                                       at java.lang.reflect.Constructor.newInstance0(Native Method)
                                                       at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
                                                       at android.view.LayoutInflater.createView(LayoutInflater.java:652)
                                                       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:794)
                                                       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:734)
                                                       at android.view.LayoutInflater.rInflate(LayoutInflater.java:865)
                                                       at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:828)
                                                       at android.view.LayoutInflater.inflate(LayoutInflater.java:525)
                                                       at android.view.LayoutInflater.inflate(LayoutInflater.java:427)
                                                       at android.view.LayoutInflater.inflate(LayoutInflater.java:378)
                                                       at android.support.v7.app.ap.b(Unknown Source)
                                                       at android.support.v7.app.z.setContentView(Unknown Source)
                                                       at com.example.user.matelacc.MenuActivity.onCreate(Unknown Source)
                                                       at android.app.Activity.performCreate(Activity.java:6955)
                                                       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126)
                                                       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2927)
                                                       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3045)
                                                       at android.app.ActivityThread.-wrap14(ActivityThread.java)
                                                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1642)
                                                       at android.os.Handler.dispatchMessage(Handler.java:102)
                                                       at android.os.Looper.loop(Looper.java:154)
                                                       at android.app.ActivityThread.main(ActivityThread.java:6776)
                                                       at java.lang.reflect.Method.invoke(Native Method)
                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496)
                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386)

0 个答案:

没有答案