5

If I don't run pro-guard on my project, everything is fine but if I run pro-guard and install .apk in device, I am getting above error. I tried adding following lines in proguard-android.txt file

-keep public class twitter4j.conf.PropertyConfigurationFactory

-dontwarn twitter4j.**

but it did not make any difference.

I am using default proguard-android.txt file from SDK

and setting it in project.properties like below

proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

I had a look at this link for same issue but could not understand that and also googling did not helped me much.

So, could anybody please tell me what is wrong here?

Thanks in advance

Edit :

Logcat error after removing public qualifier:

04-18 12:05:25.425: E/AndroidRuntime(16405): FATAL EXCEPTION: main
04-18 12:05:25.425: E/AndroidRuntime(16405): java.lang.ExceptionInInitializerError
04-18 12:05:25.425: E/AndroidRuntime(16405):    at twitter4j.b.a.h.<init>(Unknown Source)
04-18 12:05:25.425: E/AndroidRuntime(16405):    at twitter4j.ap.a(Unknown Source)
04-18 12:05:25.425: E/AndroidRuntime(16405):    at twitter4j.ap.<init>(Unknown Source)
04-18 12:05:25.425: E/AndroidRuntime(16405):    at twitter4j.aq.<init>(Unknown Source)
04-18 12:05:25.425: E/AndroidRuntime(16405):    at twitter4j.al.<init>(Unknown Source)
04-18 12:05:25.425: E/AndroidRuntime(16405):    at twitter4j.ao.a(Unknown Source)
04-18 12:05:25.425: E/AndroidRuntime(16405):    at twitter4j.ao.a(Unknown Source)
04-18 12:05:25.425: E/AndroidRuntime(16405):    at com.mobinius.creativepad.c.f.<init>(Unknown Source)
04-18 12:05:25.425: E/AndroidRuntime(16405):    at com.mobinius.creativepad.c.a.<init>(Unknown Source)
04-18 12:05:25.425: E/AndroidRuntime(16405):    at com.mobinius.creativepad.android.OpenScreenActivity.e(Unknown Source)
04-18 12:05:25.425: E/AndroidRuntime(16405):    at com.mobinius.creativepad.android.OpenScreenActivity.onClick(Unknown Source)
04-18 12:05:25.425: E/AndroidRuntime(16405):    at android.view.View.performClick(View.java:4232)
04-18 12:05:25.425: E/AndroidRuntime(16405):    at android.view.View$PerformClick.run(View.java:17298)
04-18 12:05:25.425: E/AndroidRuntime(16405):    at android.os.Handler.handleCallback(Handler.java:615)
04-18 12:05:25.425: E/AndroidRuntime(16405):    at android.os.Handler.dispatchMessage(Handler.java:92)
04-18 12:05:25.425: E/AndroidRuntime(16405):    at android.os.Looper.loop(Looper.java:137)
04-18 12:05:25.425: E/AndroidRuntime(16405):    at android.app.ActivityThread.main(ActivityThread.java:4921)
04-18 12:05:25.425: E/AndroidRuntime(16405):    at java.lang.reflect.Method.invokeNative(Native Method)
04-18 12:05:25.425: E/AndroidRuntime(16405):    at java.lang.reflect.Method.invoke(Method.java:511)
04-18 12:05:25.425: E/AndroidRuntime(16405):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
04-18 12:05:25.425: E/AndroidRuntime(16405):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
04-18 12:05:25.425: E/AndroidRuntime(16405):    at dalvik.system.NativeStart.main(Native Method)
04-18 12:05:25.425: E/AndroidRuntime(16405): Caused by: java.lang.AssertionError: java.lang.NoSuchMethodException: <init> [interface twitter4j.b.a.d]
04-18 12:05:25.425: E/AndroidRuntime(16405):    at twitter4j.b.a.e.<clinit>(Unknown Source)
04-18 12:05:25.425: E/AndroidRuntime(16405):    ... 22 more
04-18 12:05:25.425: E/AndroidRuntime(16405): Caused by: java.lang.NoSuchMethodException: <init> [interface twitter4j.b.a.d]
04-18 12:05:25.425: E/AndroidRuntime(16405):    at java.lang.Class.getConstructorOrMethod(Class.java:460)
04-18 12:05:25.425: E/AndroidRuntime(16405):    at java.lang.Class.getConstructor(Class.java:431)
04-18 12:05:25.425: E/AndroidRuntime(16405): 
Braj
  • 2,164
  • 2
  • 26
  • 44

1 Answers1

5

The class is not public, so you should remove the "public" keyword in your -keep option, or the template won't match.

Eric Lafortune
  • 45,150
  • 8
  • 114
  • 106
  • Thank u for d response. I will try this. – Braj Apr 18 '13 at 05:52
  • I am getting new error. Please have a look at edit. – Braj Apr 18 '13 at 06:34
  • That's a different issue. Cfr. ProGuard manual > Troubleshooting > NoSuchMethodException. – Eric Lafortune Apr 20 '13 at 22:45
  • Thank u Eric. I will have a look at it. – Braj Apr 22 '13 at 06:27
  • Simply adding this line removed the class not found exception in my case. "-keep class twitter4j.conf.PropertyConfigurationFactory" It was stated in developer.android.com/tools/help/proguard.html that: The default proguard.cfg file tries to cover general cases, but you might encounter exceptions such as ClassNotFoundException, which happens when ProGuard strips away an entire class that your application calls. You can fix errors when ProGuard strips away your code by adding a -keep line in the proguard.cfg file. For example: -keep public class – Reaz Murshed Jan 14 '15 at 06:29