0

我刚刚创建了一个应用程序,它使用 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。

4

1 回答 1

1

这是您的 Facebook 密钥哈希问题。请从您的系统生成您的密钥哈希并将该密钥哈希粘贴到您的 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 签名过程。两个哈希密钥不同,请尝试使用相同的密钥哈希对 apk 进行签名。当您签署 apk 时使用现有的密钥库,并且密码很可能是 android.try this step this将工作。

于 2013-05-08T06:53:55.220 回答