Marcus J.Kennedy
Marcus J.Kennedy

Reputation: 678

App crash if enabled proguard

If enable proguard in my application with this code:

release {
            debuggable false
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }

Application crash only if published in Play Store when try to run in Debug or Normal mode from Android Studio applcation not crash.

Error when crash:

Error inflating class android.support.v7.widget.Toolbar

Caused by: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class android.support.v7.widget.Toolbar

 Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class android.support.v7.widget.Toolbar

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.widget.aj.a()' on a null object reference

I m using latest version for support.v7:

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:27.0.2'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:support-v4:27.0.2'
    implementation 'com.google.firebase:firebase-messaging:11.8.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'      
}

Before today all working fine =(

Dexter say:

-dontwarn android.support.v7.**
-keep class android.support.v7.widget.** { *; }

and it work but why after any update of android studio i have always problem?? Why Android Studio after latest version of today proguard cancel widget?

Upvotes: 2

Views: 923

Answers (2)

jeprubio
jeprubio

Reputation: 18002

Try adding in Gradle:

android {  
    defaultConfig {  
        vectorDrawables.useSupportLibrary = true  
    }
}

And perform a full clean and rebuild of all the project.

Upvotes: 1

Dexter
Dexter

Reputation: 754

Maybe proguard removes this class, you can disable proguard to avoid this error if you want keep it you will have to change proguard settings

-dontwarn android.support.v7.**
-keep class android.support.v7.widget.** { *; }

Upvotes: 2

Related Questions