Vincent Mimoun-Prat
Vincent Mimoun-Prat

Reputation: 28551

Android + Facebook Connect not working in release build

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, ...

Upvotes: 2

Views: 30537

Answers (4)

webdeb
webdeb

Reputation: 13211

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

Upvotes: 0

Scott
Scott

Reputation: 31

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.

Upvotes: 2

berglind0sk
berglind0sk

Reputation: 73

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)

Upvotes: 2

Vincent Mimoun-Prat
Vincent Mimoun-Prat

Reputation: 28551

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>; 
} 

Upvotes: 3

Related Questions