Question

I've just finished my application, so I wanted to obfuscate it with ProGuard. The application uses holoeverywhere and Action Bar Sherlock libraries, so I tried to told it to ProGuard. I'm using Eclipse, and this is the project.properties file:

# 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

I haven't add anything and I haven't deleted anything.

This is my 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

If it can helps, this is the screen of my dependencies: enter image description here

I don't get errors or warning when I export the application, but when I install it on my android phone, I open it and it crashes. This is the 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

How can I fix it?

No correct solution

OTHER TIPS

-keep class com.actionbarsherlock.** { *; }
-keep interface com.actionbarsherlock.** { *; }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top