与twitter4j的android Proguard混淆
作者:互联网
我试图在twitter4j上使用proguard,并在调用新的TwitterFactory(配置)时不断收到noMethodFound异常.这是例外:
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)
在我的proguard配置(与twitter相关)是:
-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.**
问题是,TwitterFactory没有使用Configuration和Authorization对象作为参数的构造函数.我不知道为什么要寻找这样的方法……
请帮忙?
解决方法:
我对Twitter 4j的proguard配置如下: –
-dontwarn twitter4j.**
-keep class twitter4j.conf.PropertyConfigurationFactory
-keep class twitter4j.** { *; }
我也使用编译’org.twitter4j:twitter4j-core:4.0.2′
请让我知道这对你有没有用.
标签:android,obfuscation,proguard,twitter4j 来源: https://codeday.me/bug/20190716/1476693.html