2

我刚刚完成了我的应用程序,所以我想用 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

如果有帮助,这是我的依赖项的屏幕: 在此处输入图像描述

导出应用程序时我没有收到错误或警告,但是当我将它安装到我的 android 手机上时,我打开它并崩溃。这是堆栈跟踪:

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

我该如何解决?

4

1 回答 1

2
-keep class com.actionbarsherlock.** { *; }
-keep interface com.actionbarsherlock.** { *; }
于 2014-02-19T02:12:45.850 回答