Facebook Android SDK未注册安装 [英] Facebook Android SDK not registering installs

查看:169
本文介绍了Facebook Android SDK未注册安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Unity中创建了一个应用程序,并将其发布到Eclipse的Android项目中,然后将Facebook SDK包含在项目中,我也在开发人员网站中跟随入门向导。



我将以下代码行添加到主要活动的onResume()函数中:

  com.facebook .AppEventsLogger.activateApp(这是我的FB APP ID); 

在应用的清单文件中,我添加了以下内容:

 < activity android:configChanges =fontScale | keyboard | keyboardHidden | locale | mnc | mcc | navigation | orientation | screenLayout | screenSize | minimizeScreenSize | uiMode | touchscreenandroid :name =com.facebook.unity.FBUnityLoginActivityandroid:theme =@ android:style / Theme.Translucent.NoTitleBar.Fullscreen> 
< / activity>
< activity android:configChanges =keyboardHidden | orientationandroid:name =com.facebook.LoginActivityandroid:theme =@ android:style / Theme.Translucent.NoTitleBar.Fullscreen>
< / activity>
< activity android:exported =trueandroid:name =com.facebook.unity.FBUnityDeepLinkingActivity>
< / activity>
< meta-data android:name =com.facebook.sdk.ApplicationIdandroid:value =@ string / facebook_app_id/>

我还将FB应用程序ID添加到res / values文件夹中的strings.xml文件。 p>

我在命令提示符下使用以下命令生成了一个哈希键(在Windows中):

  keytool -exportcert -alias androiddebugkey -keystore%HOMEPATH%\.android\debug.keystore | openssl sha1 -binary | openssl base64 

其中生成了一个28个字符的字符串,但我仍然没有看到任何在Android上注册的应用安装。
所以搜索更多之后,我在此页面上找到以下代码: https://开发人员.facebook.com / docs / android / get-started

  //添加代码打印出关键哈希
try {
PackageInfo info = getPackageManager()。getPackageInfo(
com.facebook.samples.hellofacebook,
PackageManager.GET_SIGNATURES);
(签名签名: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){

}

我将包名称从com.facebook.samples.hellofacebook更改为我的应用程序的包名,将其添加到onCreate()函数的主要活动,并运行代码,其中记录了一个哈希键。我将返回的密钥复制到facebook开发者网站上的应用设置中,但是我仍然没有在Android上注册任何安装或事件。



我还有一个iOS版本的应用程序,一切都正常工作。



我真的很感激任何建议/想法/任何关于如何让Facebook SDK在Android上注册安装和事件

解决方案

在我的情况下,问题是将meta添加到调试清单


I created an app in Unity and published it to an Eclipse Android project, then I included the Facebook SDK in the project, I also followed the getting started wizard in the developer site.

I added the following line of code to the onResume() function of my main activity:

com.facebook.AppEventsLogger.activateApp(this, "MY FB APP ID");

In the Manifest file of the app I added the following:

<activity android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:name="com.facebook.unity.FBUnityLoginActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen">
    </activity>
    <activity android:configChanges="keyboardHidden|orientation" android:name="com.facebook.LoginActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen">
    </activity>
    <activity android:exported="true" android:name="com.facebook.unity.FBUnityDeepLinkingActivity">
    </activity>
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id" />

I also added the FB app Id to the strings.xml file in res/values folder.

I generated a Hash Key (in windows) with the following command in command prompt:

keytool -exportcert -alias androiddebugkey -keystore %HOMEPATH%\.android\debug.keystore | openssl sha1 -binary | openssl base64

Which generated a 28 character string, but I still did not see any app installs registered on Android. So after searching more I found the following code on this page https://developers.facebook.com/docs/android/getting-started

    // Add code to print out the key hash
    try {
        PackageInfo info = getPackageManager().getPackageInfo(
                "com.facebook.samples.hellofacebook", 
                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) {

    }

I changed the package name from "com.facebook.samples.hellofacebook" to the package name of my app, added it to the onCreate() function of the main activity, and ran the code, which logged a hash key. I copied the returned key into the app settings on the facebook developer site, but I am still not getting any installs or events registering on Android.

I also have an iOS version of the app and there everything is working perfectly.

I would really appreciate any suggestions/ideas/anything as to how to get the Facebook SDK to register installs and events on Android.

解决方案

in my case the problem was adding the meta to the debug manifest

这篇关于Facebook Android SDK未注册安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆