当ProGuard被禁用时,我的应用程序正常运行.
启用ProGuard后,应用程序将导出到apk并安装到模拟器中.
然后当我在模拟器中运行它时,强制关闭...
05-10 11:14:10.582: E/AndroidRuntime(759): FATAL EXCEPTION: main 05-10 11:14:10.582: E/AndroidRuntime(759): java.lang.NoSuchMethodError: android.util.Xml.asAttributeSet 05-10 11:14:10.582: E/AndroidRuntime(759): at com.actionbarsherlock.view.MenuInflater.inflate(Unknown Source) 05-10 11:14:10.582: E/AndroidRuntime(759): at com.g.myapp.e.onCreateOptionsMenu(Unknown Source) 05-10 11:14:10.582: E/AndroidRuntime(759): at android.support.v4.app.Watson.onCreatePanelMenu(Unknown Source) 05-10 11:14:10.582: E/AndroidRuntime(759): at com.actionbarsherlock.ActionBarSherlock.callbackCreateOptionsMenu(Unknown Source) 05-10 11:14:10.582: E/AndroidRuntime(759): at com.actionbarsherlock.internal.ActionBarSherlockNative.dispatchCreateOptionsMenu(Unknown Source) 05-10 11:14:10.582: E/AndroidRuntime(759): at com.actionbarsherlock.app.SherlockFragmentActivity.onCreatePanelMenu(Unknown Source) 05-10 11:14:10.582: E/AndroidRuntime(759): at com.android.internal.policy.impl.PhoneWindow.preparePanel(PhoneWindow.java:393) 05-10 11:14:10.582: E/AndroidRuntime(759): at com.android.internal.policy.impl.PhoneWindow.invalidatePanelMenu(PhoneWindow.java:747) 05-10 11:14:10.582: E/AndroidRuntime(759): at com.actionbarsherlock.internal.ActionBarSherlockNative.dispatchInvalidateOptionsMenu(Unknown Source) 05-10 11:14:10.582: E/AndroidRuntime(759): at com.actionbarsherlock.app.SherlockFragmentActivity.invalidateOptionsMenu(Unknown Source) 05-10 11:14:10.582: E/AndroidRuntime(759): at com.actionbarsherlock.app.SherlockFragmentActivity.supportInvalidateOptionsMenu(Unknown Source) 05-10 11:14:10.582: E/AndroidRuntime(759): at android.support.v4.app.Fragment.setHasOptionsMenu(Unknown Source) 05-10 11:14:10.582: E/AndroidRuntime(759): at com.g.myapp.e.onCreate(Unknown Source) 05-10 11:14:10.582: E/AndroidRuntime(759): at android.support.v4.app.FragmentManagerImpl.moveToState(Unknown Source) 05-10 11:14:10.582: E/AndroidRuntime(759): at android.support.v4.app.FragmentManagerImpl.moveToState(Unknown Source) 05-10 11:14:10.582: E/AndroidRuntime(759): at android.support.v4.app.BackStackRecord.run(Unknown Source) 05-10 11:14:10.582: E/AndroidRuntime(759): at android.support.v4.app.FragmentManagerImpl.execPendingActions(Unknown Source) 05-10 11:14:10.582: E/AndroidRuntime(759): at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(Unknown Source) 05-10 11:14:10.582: E/AndroidRuntime(759): at com.g.myapp.n.onTabChanged(Unknown Source) 05-10 11:14:10.582: E/AndroidRuntime(759): at android.widget.TabHost.invokeOnTabChangeListener(TabHost.java:391) 05-10 11:14:10.582: E/AndroidRuntime(759): at android.widget.TabHost.setCurrentTab(TabHost.java:376) 05-10 11:14:10.582: E/AndroidRuntime(759): at android.widget.TabHost.addTab(TabHost.java:236) 05-10 11:14:10.582: E/AndroidRuntime(759): at com.g.myapp.n.a(Unknown Source) 05-10 11:14:10.582: E/AndroidRuntime(759): at com.g.myapp.MainActivity.onCreate(Unknown Source) 05-10 11:14:10.582: E/AndroidRuntime(759): at android.app.Activity.performCreate(Activity.java:5008) 05-10 11:14:10.582: E/AndroidRuntime(759): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079) 05-10 11:14:10.582: E/AndroidRuntime(759): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023) 05-10 11:14:10.582: E/AndroidRuntime(759): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084) 05-10 11:14:10.582: E/AndroidRuntime(759): at android.app.ActivityThread.access$600(ActivityThread.java:130) 05-10 11:14:10.582: E/AndroidRuntime(759): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195) 05-10 11:14:10.582: E/AndroidRuntime(759): at android.os.Handler.dispatchMessage(Handler.java:99) 05-10 11:14:10.582: E/AndroidRuntime(759): at android.os.Looper.loop(Looper.java:137) 05-10 11:14:10.582: E/AndroidRuntime(759): at android.app.ActivityThread.main(ActivityThread.java:4745) 05-10 11:14:10.582: E/AndroidRuntime(759): at java.lang.reflect.Method.invokeNative(Native Method) 05-10 11:14:10.582: E/AndroidRuntime(759): at java.lang.reflect.Method.invoke(Method.java:511) 05-10 11:14:10.582: E/AndroidRuntime(759): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 05-10 11:14:10.582: E/AndroidRuntime(759): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 05-10 11:14:10.582: E/AndroidRuntime(759): at dalvik.system.NativeStart.main(Native Method)
ProGuard的-project.txt:
-keep class android.support.v4.app.** { *; } -keep interface android.support.v4.app.** { *; } -keep class com.actionbarsherlock.** { *; } -keep interface com.actionbarsherlock.** { *; } -keepattributes *Annotation* -dontwarn org.w3c.dom.bootstrap.** -dontwarn org.joda.time.** -dontwarn org.xmlpull.v1.**
我该如何修复错误?
非常感谢你!
更新:
在proguard-project.txt中添加一行后,可以在模拟器中运行该应用:
-keep class * { *; }
虽然应用程序可以运行,但我认为这个解决方案可能不太好......
更好的解决方案?
请帮忙.
非常感谢.
在proguard-project.txt中添加一行:
-keep class org.xmlpull.v1.** { *; }