Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

minifyEnabled true leads to crash on app start

Unfortunately XX has stopped.

I receive this message as soon as I start my productive app, when I set

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

I do not have any additional proguard-rules (cause no library stated that it is necessary).

My dependencies look like this:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.loopj.android:android-async-http:1.4.9'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile 'com.google.android.gms:play-services-gcm:8.4.0'
    compile 'com.google.android.gms:play-services-ads:8.4.0'
    compile 'me.leolin:ShortcutBadger:1.1.4@aar'
    compile 'com.facebook.android:facebook-android-sdk:4.+'
    compile 'com.jraska:falcon:1.0.0'
}

What I tried was to add

-keep class com.loopj.** {*;}
-keep class com.jraska.** {*;}
-keep class me.leolin.** {*;}
-keep class com.android.** {*;}
-keep class com.google.** {*;}
-keep class com.facebook.** {*;}

to my proguard-rules, but still the same error. Any idea?

like image 904
Chris Avatar asked Mar 27 '16 15:03

Chris


1 Answers

So I found the error in the log

W/SupportMenuInflater(29041): Cannot instantiate class: android.support.v7.widget.SearchView
W/SupportMenuInflater(29041): java.lang.NoSuchMethodException: <init> [class android.content.Context]

After adding

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

to my proguard-rules file, everything worked as expected.

like image 148
Chris Avatar answered Nov 15 '22 12:11

Chris