Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Proguard android app which uses support lib crashes

I've got android app wihch uses support lib. It was obfuscated with Proguard, and itcrashes on Home Activity on code:

` @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.home, menu); //ith crashes here
        return true;        
    } `

throwing:

java.lang.NoSuchMethodError: android.util.Xml.asAttributeSet at android.support.v7.internal.view.SupportMenuInflater.inflate(Unknown Source) at com.sample.mobile.HomeActivity.onCreateOptionsMenu(Unknown Source)

I've enabled proGuard using :

proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

in project.properties

My config file looks like this:

-libraryjars libs
-libraryjars C:\adt-bundle-windows-x86_64-20131030\sdk\platforms\android-19\android.jar

-keep class android.support.v4.app.** { *; }
-keep interface android.support.v4.app.** { *; }
-keep class android.support.v7.app.** { *; }
-keep interface android.support.v7.app.** { *; }
-keep class android.support.v7.internal.** { *; }
-keep interface android.support.v7.internal.** { *; }
-keep class android.util.Xml..** { *; }

-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.billing.IInAppBillingService

-keep public class * extends android.view.View {
    public <init>(android.content.Context);
    public <init>(android.content.Context, android.util.AttributeSet);
    public <init>(android.content.Context, android.util.AttributeSet, int);
    public void set*(...);
}
-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers class * extends android.content.Context {
    public void *(android.view.View);
    public void *(android.view.MenuItem);
}

I added many thing, cos I was looking for solution for this problem.

like image 726
Dawid C Avatar asked Mar 12 '14 16:03

Dawid C


1 Answers

I am not sure how it is happened. But adding following line to proguard rules solve the problem.

-keep class org.xmlpull.v1.** { *; }

like image 111
SafeHouse Avatar answered Nov 09 '22 06:11

SafeHouse