Android + Facebook Connect not working in release build

孤人 提交于 2019-11-28 10:19:23

问题


I have an Android application that allows the user to connect to his Facebook account and automatically make a post on his wall.

All this is perfectly working with the debug build (using either the fallback webview dialog or the native application activity). I am using the latest Facebook Connect API for Android.

When testing the release version of the application, I noticed that the fallback webview dialog does not allow to connect to Facebook (after entering the username/password, it shows a standard 404 page that says it could not find the page fbconnect:/success/#access_token=3213546...)

I suspect proguard has stripped some code but I cannot figure out how to determine what is causing the problem. Could anybody give some clues and get me going in the right direction?

My proguard.cfg file contains the following lines to leave Facebook Connect alone:

-keep class com.facebook.android.*
-keepclassmembers public class com.facebook.android.Facebook { 
    public static final *; 
}

In usage.txt I can see the facebook classes, string members, ...


回答1:


I fixed it with the following rules (however I am no expert so there might be mistakes in there).

-keep class com.facebook.android.*
-keep class android.webkit.WebViewClient
-keep class * extends android.webkit.WebViewClient
-keepclassmembers class * extends android.webkit.WebViewClient { 
    <methods>; 
} 



回答2:


This is the only thing that worked for me with facebook sdk 3.0:

-keepattributes Signature

-dontwarn com.facebook.**

-dontwarn com.parse.**

-keep class com.facebook.** { *; }

-keep class com.parse.** { *; }

(got this from http://adilatwork.blogspot.com/2013/01/parse-android-sdk-facebook-and-proguard.html)




回答3:


I was getting the error Webpage not available fbconnect://success#access_token=... When using an existing app (Draw Something) that connects to facebook. The problem went away when I uninstalled the two different facebook apps i had installed on my phone (Galaxy note 2 with Android 4.1.2) and reinstalled the current facebook app.




回答4:


To make facebookConnect work with an android release build you need to create a reference to the keystore file, which you have used for signing your app.

on a mac:

keytool -exportcert -alias <RELEASE_KEY_ALIAS> -keystore <RELEASE_KEY_PATH> | openssl sha1 -binary | openssl base64

on win:

keytool -exportcert -alias <RELEASE_KEY_ALIAS> -keystore <RELEASE_KEY_PATH> | openssl sha1 -binary | openssl base64

the output should be set in Android -> Key Hashes in Facebook settings



来源:https://stackoverflow.com/questions/6108397/android-facebook-connect-not-working-in-release-build

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!