0

我正在尝试让 facebook 集成与我的一个应用程序一起工作。我刚刚阅读了此处的文档,其中说:

“首先,要在本地计算机上生成密钥哈希,请针对 Android 调试密钥库运行 Java 的 keytool 实用程序(它应该在控制台的路径上)。”

这让我很困惑,这是否意味着我的应用程序(+facebook 集成)只能在我的“本地计算机”上运行 - 即在我的 PC 上运行的模拟器?.. 如果是这样,是否有某种方法可以获得我的安卓手机(通过 USB 连接到我的电脑)对应的“密钥哈希”?因为我更愿意在手机上测试我的应用程序而不是模拟器。

4

1 回答 1

1

When you create an Android application that will be uploaded to the Google Play store, you generate a unique identifier that will allow Google, as well as every phone that installs your app, to know that you developed it. It is like your own secret password that you shouldn't share with anyone. If a malicious developer creates an "update" to your app, and somehow were to distribute it as such to users, any user that tried to install it would receive an error message because the malicious fake upgrade would not have been created with your private keystore. When you release your app, you'll have to make this keystore, as well as use it to generate a Facebook key hash, which is what they are referring to here.

However, when you are developing and not ready to release to the world, by default Eclipse will build your application using the default "debug" keystore. The instructions that you are referring to tell you how to generate the Facebook hash with your debug keystore. Once you do that, whenever you build your app with the debug keystore and run it, Facebook will allow it to connect using the SDK, as long as you have pasted that key hash into the Facebook developer console. It does not matter whether you are running the app on your computer or phone, it will run and connect with Facebook integration.

When you are ready to release, you'll have to generate a brand new keystore, run the tool again on that file, and upload that key hash to Facebook as before. Then, your app can run on anyone's phone and be able to connect to Facebook, provided you build it with the new keystore.

于 2013-04-07T16:01:27.130 回答