我有一个使用了support库的安卓应用,它经过了Proguard混淆。但是在主页面(Home Activity)上的以下代码会导致崩溃:
` @Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.home, menu); //ith crashes here
return true;
} `
抛出异常:
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)
我使用以下方法启用了proGuard:
proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
在project.properties中
我的配置文件如下:
-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);
}
我添加了许多东西,因为我正在寻找解决这个问题的方法。