简体   繁体   English

Android Facebook SDK 3.0在登录时提供“remote_app_id与存储的ID不匹配”

[英]Android Facebook SDK 3.0 gives “remote_app_id does not match stored id” while logging in

I'm trying to build a app that uses Facebook SDK for Android 3.0. 我正在尝试构建一个使用Facebook SDK for Android 3.0的应用程序。 But when I'm trying to call 但是当我试着打电话的时候

Session.openActiveSession

It just simply gives me a SessionState with CLOSED_LOGIN_FAILED, and LogCat is: 它只是简单地给我一个CLOSED_LOGIN_FAILED的SessionState,LogCat是:

12-16 00:03:40.510: W/fb4a:fb:OrcaServiceQueue(4105): com.facebook.orca.protocol.base.ApiException: remote_app_id does not match stored id 

I have searched StackOverflow with "remote_app_id" and the results are the "Bundle ID" in iOS, but I don't know what does the "remote_app_id" means in Android. 我用“remote_app_id”搜索了StackOverflow,结果是iOS中的“Bundle ID”,但我不知道“remote_app_id”在Android中是什么意思。 I have already set the package name and the activity name in my Facebook app settings. 我已经在我的Facebook应用设置中设置了包名和活动名称。 I have no idea of the reason of the error. 我不知道错误的原因。

Another possible error (which happened with me) is: to set up a "Key Hash" at Facebook App Console and to sign the android app using another keystore. 另一个可能的错误(发生在我身上)是:在Facebook App Console上设置“Key Hash”,并使用另一个密钥库对Android应用程序进行签名。

Unfortunately this is caused because Facebook Getting Started Tutorial induces this error. 不幸的是,这是因为Facebook入门教程引发了这个错误。 It says that android developers should use default android debug key in your examples and doesn't explain that the Key Hash should be generated with the same keystore you will sign your application. 它说android开发人员应该在你的例子中使用默认的android调试密钥,并没有解释应该使用你将为你的应用程序签名的相同密钥库生成Key Hash。

My recomendation is to set up two Key Hashes at your facebook console: 我的推荐是在你的facebook控制台上设置两个Key Hashes:

  1. default android debug key: 默认的android调试密钥:

keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | keytool -exportcert -alias androiddebugkey -keystore~ / .android / debug.keystore | openssl sha1 -binary | openssl sha1 -binary | openssl base64 openssl base64

  1. your application release key: 你的应用发布密钥:

keytool -exportcert -alias yourappreleasekeyalias -keystore ~/.your/path/release.keystore | keytool -exportcert -alias yourappreleasekeyalias -keystore~ / .your / path / release.keystore | openssl sha1 -binary | openssl sha1 -binary | openssl base64 openssl base64

Remember: you cannot publish an application that is signed with the debug key generated by the SDK tools. 请记住:您无法发布使用SDK工具生成的调试密钥签名的应用程序。 So it isn't possible to publish an app using only the hash key generated using the first previous command line (as facebook tutorial suggests. 因此,不可能仅使用使用第一个上一个命令行生成的哈希键来发布应用程序(如Facebook教程所示)。

For more information about signing your application, visit Signing Your Application . 有关签署应用程序的更多信息,请访问签署您的应用程序

Another option is to print out the key hash sent to Facebook and use that value. 另一个选择是打印发送到Facebook的密钥哈希并使用该值。

Make the following changes to the onCreate() method in your main activity: 对主活动中的onCreate()方法进行以下更改:

try {
    PackageInfo info = getPackageManager().getPackageInfo(
          "com.facebook.samples.loginhowto", PackageManager.GET_SIGNATURES);
    for (Signature signature : info.signatures){
           MessageDigest md = MessageDigest.getInstance("SHA");
           md.update(signature.toByteArray());
           Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
    }
} catch (NameNotFoundException e) {
} catch (NoSuchAlgorithmException e) {
}

Replace com.facebook.samples.loginhowto with your own package name . com.facebook.samples.loginhowto替换为your own package name

This worked for me! 这对我有用!

I solved this question. 我解决了这个问题。 The problem is, the "Key Hash" which I generated using "keytool" was wrong. 问题是,我使用“keytool”生成的“Key Hash”是错误的。 When the "keytool" prompts for a password, you have to use "android" for it (without quotes). 当“keytool”提示输入密码时,你必须使用“android”(没有引号)。 I was using my own password instead. 我正在使用自己的密码。 When I changed my password, the problem just flew away. 当我更改密码时,问题就消失了。 Hope this helps. 希望这可以帮助。

I've got trapped by wrong openssl, that generated wrong hash key. 我被错误的openssl困住,生成错误的哈希键。 i used openssl from http://gnuwin32.sourceforge.net/packages/openssl.htm that solved the problem. 我使用http://gnuwin32.sourceforge.net/packages/openssl.htm中的openssl解决了这个问题。

I had the same problem, found out that the openssl was creating the wrong sha1. 我遇到了同样的问题,发现openssl正在创建错误的sha1。 downloaded a new one and it worked like a charm. 下载了一个新的,它就像一个魅力。

Also, make sure that you enter the hash in the correct place in the facebook dev portal. 此外,请确保在facebook dev门户中的正确位置输入哈希值。 Edit application settings and select Native Android App. 编辑应用程序设置并选择Native Android App。

I had mistakenly put the hash in the 'Sample App Settings' instead. 我错误地将哈希放在“示例应用程序设置”中。

You are getting the hash-key with debug key... Which may work if you haven't sign the package and running app in debug mode. 您正在使用调试密钥获取哈希键...如果您未在调试模式下签署包并运行应用程序,则可能会有效。 What you need to do is : 你需要做的是:

1) Go to the manifest file and add to the application android:debuggable="true". 1)转到清单文件并添加到应用程序android:debuggable =“true”。

2) Now run your app and monitor the logcat. 2)现在运行您的应用程序并监控logcat。

3) You will get printed a new key which will be the matching key with x9SLcMXBlgly1f36PJuuc4a3YAc, The key you have got is now having a = sign in the last. 3)你将得到一个新的密钥,它将是与x9SLcMXBlgly1f36PJuuc4a3YAc匹配的密钥,你得到的密钥现在在最后一个有一个=符号。

4) Register this key on facbook developer site 4)在facbook开发者网站上注册此密钥

Alternate Trick 替代技巧

You can do one other thing Simply register this key to the facebook developers site x9SLcMXBlgly1f36PJuuc4a3YAc= 你可以做另外一件事只需将这个密钥注册到facebook开发者网站x9SLcMXBlgly1f36PJuuc4a3YAc =

Just add = to the key which is being shown by the facebook app. 只需将=添加到Facebook应用程序显示的键即可。

you are done!! 你完成了!! Hope this will work. 希望这会奏效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用Facebook SDK 3.5 android remote_app_id的简单帖子与存储的ID不匹配 - Simple post with facebook sdk 3.5 android remote_app_id does not match stored id Facebook消息remote_app_id与存储的ID不匹配 - Facebook message remote_app_id does not match stored id Android仍然:remote_app_id与存储的ID不匹配 - Android still: remote_app_id does not match stored id Android Facebook Api异常 - remote_app_id与存储的ID不匹配 - Android Facebook Api Exception - remote_app_id does not match stored id Android Facebook remote_app_id与存储的ID错误不匹配 - Android Facebook remote_app_id does not match stored id Error Android Facebook登录错误-'remote_app_id与存储的ID不匹配' - Android Facebook sign in error - 'remote_app_id does not match stored id' Android Facebook密钥哈希-“ remote_app_id与存储的ID不匹配” - Android Facebook key hash — “remote_app_id does not match stored id” com.facebook.http.protocol.ApiException:remote_app_id与Facebook SDK 3.5中存储的ID不匹配 - com.facebook.http.protocol.ApiException: remote_app_id does not match stored id with Facebook SDK 3.5 remote_app_id与存储的id - 异常不匹配 - remote_app_id does not match stored id - exception FacebookAuthorizationException:UnknownError:remote_app_id与FB SDK 3.5上存储的ID不匹配 - FacebookAuthorizationException: UnknownError: remote_app_id does not match stored id on FB SDK 3.5
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM