使用proguard混淆后社交身份验证崩溃

时间:2014-12-08 17:32:17

标签: facebook authentication twitter proguard obfuscation

我有一个使用社交认证(Twitter和Facebook)的应用程序。在app store中发布之前,我使用proguard来模糊我的代码。除了Facebook和Twitter的身份验证外,所有功能都可以正常工只要我点击使用Facebook登录或使用Twitter按钮登录,应用程序就会崩溃,但不幸的是“APP名称”已停止。 我的twitter认证类扩展了Activity和TwiterProfile.java类扩展了片段。

这是我的proguard配置

-injars      bin/classes
-injars      libs
-outjars     bin/classes-processed.jar
-libraryjars libs\ksoap2-android-assembly-2.4-jar-with-dependencies.jar
-libraryjars libs\twitter4j-core-4.0.1.jar
-dontpreverify
-repackageclasses ''
-allowaccessmodification
-optimizations !code/simplification/arithmetic
-keepattributes *Annotation*
-dontwarn twitter4j.**
-dontwarn org.xmlpull.v1.**
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.support.v4.app.Fragment
-keep public class * extends android.support.v4.app.ListFragment
-keep public class * extends android.app.Fragment
-keep public class * extends android.view.View {
    public <init>(android.content.Context);
    public <init>(android.content.Context, android.util.AttributeSet);
    public <init>(android.content.Context, android.util.AttributeSet, int);
    public void set*(...);
}

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet);
}

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet, int);
}

-keepclassmembers class * extends android.content.Context {
   public void *(android.view.View);
   public void *(android.view.MenuItem);
}

-keepclassmembers class * implements android.os.Parcelable {
    static ** CREATOR;
}

-keepclassmembers class **.R$* {
    public static <fields>;
}

-keepclassmembers class * {
    @android.webkit.JavascriptInterface <methods>;
}

这是从TwitterProfile.java类调用的twitterauthentication.java

public class TwitterAuthenticate extends Activity{
    private WebView webView;

    public static String EXTRA_URL = "extra_url";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_webview);

        setTitle("Twitter");

        final String url = this.getIntent().getStringExtra(EXTRA_URL);
        if (null == url) {
            Log.e("Twitter", "URL cannot be null");
            finish();
        }

        webView = (WebView) findViewById(R.id.webView);
        webView.setWebViewClient(new MyWebViewClient());
        webView.loadUrl(url);
    }


    class MyWebViewClient extends WebViewClient {

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {

            if (url.contains(getResources().getString(R.string.twitter_callback))) {
                Uri uri = Uri.parse(url);
                /* Sending results back */
                String verifier = uri.getQueryParameter(getString(R.string.twitter_oauth_verifier));
                Intent resultIntent = new Intent();
                resultIntent.putExtra(getString(R.string.twitter_oauth_verifier), verifier);
                setResult(RESULT_OK, resultIntent);
                /* closing webview */
                finish();
                return true;
            }
            return false;
        }
    }

}

0 个答案:

没有答案