Obfuscating Proguard androids with twitter4j

I am trying to use proguard with twitter4j and keep getting noMethodFound exception when called new TwitterFactory(configuration)

. This is an exception:

java.lang.AssertionError: java.lang.NoSuchMethodException: <init> [interface twitter4j.conf.Configuration, interface twitter4j.auth.Authorization]
        at twitter4j.TwitterFactory.<clinit>(TwitterFactory.java:73)
        at com.applicaster.util.twitter.TwitterAuthenticationUtil.getServiceInstance(Unknown Source)
        at com.applicaster.util.twitter.TwitterAuthenticationUtil.logIn(Unknown Source)
        at feed.x.b(Unknown Source)
        at feed.A.onClick(Unknown Source)
        at android.view.View.performClick(View.java:4442)
        at android.view.View$PerformClick.run(View.java:18473)
        at android.os.Handler.handleCallback(Handler.java:733)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:136)
        at android.app.ActivityThread.main(ActivityThread.java:5105)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:515)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608)
        at dalvik.system.NativeStart.main(Native Method)
 Caused by: java.lang.NoSuchMethodException: <init> [interface twitter4j.conf.Configuration, interface twitter4j.auth.Authorization]
        at java.lang.Class.getConstructorOrMethod(Class.java:472)
        at java.lang.Class.getDeclaredConstructor(Class.java:562)
        at twitter4j.TwitterFactory.<clinit>(TwitterFactory.java:71)
            at com.applicaster.util.twitter.TwitterAuthenticationUtil.getServiceInstance(Unknown Source)
            at com.applicaster.util.twitter.TwitterAuthenticationUtil.logIn(Unknown Source)
            at feed.x.b(Unknown Source)
            at feed.A.onClick(Unknown Source)
            at android.view.View.performClick(View.java:4442)
            at android.view.View$PerformClick.run(View.java:18473)
            at android.os.Handler.handleCallback(Handler.java:733)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5105)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608)
            at dalvik.system.NativeStart.main(Native Method)

      

In my proguard config (in relation to twitter) there is:

    -dontoptimize
    -dontpreverify
    -dontobfuscate

    -optimizations !code/simplification/arithmetic
    -allowaccessmodification
    -repackageclasses ''
    -keepattributes *Annotation*
    -keepattributes InnerClasses
    -keepattributes Signature
    -keepattributes Exceptions
    -keepattributes JavascriptInterface
    -dontnote
    -dontwarn twitter4j.**
    -keep class twitter4j.**
    -keep public class twitter4j.TwitterFactory
    -keep interface twitter4j.**

      

The point is that there is no constructor for TwitterFactory that takes configuration and authorization objects as parameters. I have no idea why he is looking for a method like this ...

Help me please?

+3


source to share


1 answer


My proguard config for Twitter 4j looks like this: -

-dontwarn twitter4j.**
-keep  class twitter4j.conf.PropertyConfigurationFactory
-keep class twitter4j.** { *; }

      



Also I am using compile 'org.twitter4j:twitter4j-core:4.0.2'

Let me know if this works for you.

+11


source







All Articles