ProGuard使我的应用程序崩溃

时间:2014-02-18 16:36:46

标签: android actionbarsherlock obfuscation proguard holoeverywhere

我刚刚完成了我的应用程序,因此我想用ProGuard对其进行模糊处理。 该应用程序使用holoeverywhere和Action Bar Sherlock库,因此我尝试将其告知ProGuard。 我正在使用Eclipse,这是project.properties文件:

# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available         properties: sdk.dir, user.home):
proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

# Project target.
target=android-19
android.library.reference.1=..\\HoloEverywhere Addon Preferences

我没有添加任何内容,但我没有删除任何内容。

这是我的proguard-project.txt:

# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
#   http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
#   public *;
#}

-keep class com.actionbarsherlock.** 
-keep class org.holoeverywhere.**
-libraryjars adt-bundle-windows-x86_64-20130917\sdk\platforms\android-19\android.jar
-libraryjars actionbarsherlock\libs\android-support-v4.jar
-libraryjars HoloEverywhere Addon Preferences\bin\holoeverywhere addon preferences.jar
-libraryjars HoloEverywhere Library\bin\holoeverywhere library.jar
-libraryjars actionbarsherlock\bin\actionbarsherlock.jar

如果它可以帮助,这是我的依赖关系的屏幕: enter image description here

导出应用程序时,我没有收到错误或警告,但是当我在Android手机上安装它时,我打开它然后崩溃了。 这是stackTrace:

FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.my.project/com.my.project.FirstPage}: java.lang.RuntimeException: java.lang.NoSuchMethodException: AddonSherlock$HoloActionBarSherlockCompat(Activity,int)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
at android.app.ActivityThread.access$1500(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3687)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: java.lang.NoSuchMethodException: AddonSherlock$HoloActionBarSherlockCompat(Activity,int)
at com.actionbarsherlock.ActionBarSherlock.a(Unknown Source)
at org.holoeverywhere.addon.AddonSherlock$AddonSherlockA.c(Unknown Source)
at org.holoeverywhere.addon.AddonSherlock$AddonSherlockA.a(Unknown Source)
at android.support.v4.app.aw.a(Unknown Source)
at android.support.v4.app.aw.a(Unknown Source)
at org.holoeverywhere.addon.IAddonBasicAttacher.a(Unknown Source)
at org.holoeverywhere.app.Activity.a(Unknown Source)
at android.support.v4.app._HoloActivity.a(Unknown Source)
at android.support.v4.app._HoloActivity.setContentView(Unknown Source)
at com.my.project.FirstPage.onCreate(Unknown Source)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
... 11 more
Caused by: java.lang.NoSuchMethodException: AddonSherlock$HoloActionBarSherlockCompat(Activity,int)
at java.lang.Class.getMatchingConstructor(Class.java:643)
at java.lang.Class.getConstructor(Class.java:472)
... 23 more

我该如何解决?

1 个答案:

答案 0 :(得分:2)

-keep class com.actionbarsherlock.** { *; }
-keep interface com.actionbarsherlock.** { *; }