android - 获取用户信息 Facebook SDK 时签名的 Android 应用程序崩溃

标签 android crash facebook-login

我刚刚创建了一个应用程序,它使用 facebook sdk 3.0 来获取用户信息。这是代码:

private void getMe()
{
    Session session = Session.getActiveSession();
    CanBanNhanhAppActivity._fbtoken = session.getAccessToken();
    // make request to the /me API
    Request request = Request.newMeRequest(session,
            new Request.GraphUserCallback() {
        // callback after Graph API response with user object
        @Override
        public void onCompleted(GraphUser user,
                Response response) {
            //ShowDialog(response.getError().toString());
            // TODO Auto-generated method stub
        }
    });

    Request.executeBatchAsync(request);
}

早期,代码有效(通过 apk 安装也从 eclipse 部署)。
但是,最近,从 apk 安装的应用程序在调用 Request.executeBatchAsync(request); 时崩溃了。 .虽然,通过 Eclipse 构建的应用程序仍然有效。我不知道为什么。我无法调试,因为只有由 apk 安装的应用程序崩溃了。
这是权限:
private static final List PERMISSIONS = Arrays.asList( "read_stream","email", "user_photos");
p/s:我在 developer.facebook 的 App 上添加了调试和发布 hashkey。

最佳答案

这是您的 Facebook key 哈希问题。请从您的系统生成您的 key 哈希并将该 key 哈希粘贴到您的 Facebook 应用程序,然后使用 appid。
使用以下步骤生成 keyhash 然后转到您的 facebook 应用程序仪表板并编辑应用程序并将 hashkey 添加到应用程序

 In order to generate key hash you need to follow some easy steps.
1) Download Openssl from: http://code.google.com/p/openssl-for-windows/downloads/list
2) Make a openssl folder in C drive
3) Extract Zip files into openssl folder
4) Copy the File debug.keystore from .android folder in my case (C:\Users\SYSTEM.android) and paste into JDK bin Folder in my case (C:\Program Files\Java\jdk1.6.0_05\bin)
5) Open command prompt and give the path of JDK Bin folder in my case (C:\Program Files\Java\jdk1.6.0_05\bin).
6) Copy the code and hit enter keytool -exportcert -alias androiddebugkey -keystore debug.keystore > c:\openssl\bin\debug.txt
7) Now you need to enter password, Password = android.
8) See in openssl Bin folder you will get a file with the name of debug.txt
9) Now either you can restart command prompt or work with existing command prompt
10) comes to C drive and give the path of openssl Bin folder
11) copy the following code and paste openssl sha1 -binary debug.txt > debug_sha.txt
12) you will get debug_sha.txt in openssl bin folder
13) Again copy following code and paste openssl base64 -in debug_sha.txt > debug_base64.txt
14) you will get debug_base64.txt in openssl bin folder
15) open debug_base64.txt file Here is your Key hash.

引用这个博客

http://logcatsolutions.blogspot.in/2013/02/facebook-android-generate-key-hash.html



编辑:

实际上,问题的发生是因为对于您的 apk 签名过程。两个哈希 key 不同,请尝试使用相同的 key 哈希对 apk 进行签名。当您签署 apk 时使用现有的 keystore ,并且密码很可能是 android.try this step this将工作。

关于android - 获取用户信息 Facebook SDK 时签名的 Android 应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16425377/

相关文章:

android - 手势和色彩绘画

Android 在不再可见时停止异步加载列表元素

android - 如何绕过 AppWidgetManager.ACTION_APPWIDGET_PICK?

swift:计时器(每秒)+gestureRecognizer 使 GUI 崩溃

facebook - FB.logout() 在没有访问 token 的情况下调用。 JavaScript SDK

android - 在应用程序外部显示模态消息并在一段时间后自行关闭

iphone - 一个 hello world 应用程序,但导致错误 "image not found"

iphone - Alertview中的Exc_Bad_Access显示

java - 未安装 Facebook 应用程序时,Facebook 登录按钮单击失败

android - Firebase 使用预构建的 UI 登录 Facebook 登录不起作用;显示登录错误 : There is an error in logging you into this application