Facebook的SDK团结Android的 - 正在生成错误清单文件,无法登陆 [英] Facebook SDK for Unity Android - Incorrect manifest file being generated, can't login

查看:176
本文介绍了Facebook的SDK团结Android的 - 正在生成错误清单文件,无法登陆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,这已经采取了一个多星期,但我终于找到了为什么我似乎无法在我的Andr​​oid设备上使用Facebook SDK(v4.3.4)与Unity3d(V4.3)登录到Facebook的原因。现在要弄清楚如何解决它...?

Ok, this has taken over a week, but I finally found the cause of why I can't seem to log in to facebook using the Facebook SDK (v4.3.4) with Unity3d (v4.3) on my android devices. Now to figure out how to fix it... ?

症状:
我运行Android设备上的应用程序。当我preSS登录按钮,它会打开权限从Facebook提示。然后什么都没有。登录未完成,并通过日志,它明确指出,LoginCallback不被打电话找。 (虽然Facebook的appcenter的确,你已授权应用程序记录)。如果我问多个权限,只提示输入第一个。 (通常它会提示第一位,似乎回到了分裂的第二个应用程序,那么第二个再次提示)。

Symptom: I run the application on the android device. When I press the login button, it opens the permissions prompt from facebook. Then... nothing. The login doesn't complete, and looking through the logs, its clear that the LoginCallback isn't being called. (Although Facebook appcenter does record that you've granted permission to the app). If I asked for multiple permissions, it only prompts for the first one. (normally it will prompt for the first one, appear to go back to the application for a split second, then prompt again for the second).

原因:
清单文件被错误地生成。

Cause: The manifest file is being incorrectly generated.

下面是FriendSmash一个manifest文件的例子它正确时产生的:

Here's an example of the one manifest file for FriendSmash when its generated CORRECTLY:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:theme="@android:style/Theme.NoTitleBar" android:versionCode="1" android:versionName="1.0" package="com.mycompany.mygame" android:installLocation="preferExternal">
  <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:smallScreens="true" android:xlargeScreens="true" />
  <application android:icon="@drawable/app_icon" android:label="@string/app_name" android:debuggable="true">
    <activity android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:label="@string/app_name" android:launchMode="singleTask" android:name="com.facebook.unity.FBUnityPlayerActivity">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
    </activity>
    <activity android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:label="@string/app_name" android:launchMode="singleTask" android:name="com.unity3d.player.UnityPlayerActivity">
    </activity>
    <activity android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:label="@string/app_name" android:launchMode="singleTask" android:screenOrientation="reverseLandscape" android:name="com.mycompany.mygame.UnityPlayerNativeActivity">
      <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="false" />
    </activity>
    <activity android:configChanges="keyboardHidden|orientation" android:name="com.facebook.LoginActivity" android:screenOrientation="portrait">
    </activity>
    <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="\ 586438214724597" />
  </application>
  <uses-sdk android:minSdkVersion="9" android:targetSdkVersion="19" />
  <uses-feature android:glEsVersion="0x00020000" />
  <uses-permission android:name="android.permission.INTERNET" />
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
  <uses-feature android:name="android.hardware.touchscreen" />
  <uses-feature android:name="android.hardware.touchscreen.multitouch" android:required="false" />
  <uses-feature android:name="android.hardware.touchscreen.multitouch.distinct" android:required="false" />
</manifest>

下面是FriendSmash清单文件的例子它错误地生成时:

Here's an example of the manifest file for FriendSmash when its generated INCORRECTLY:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:theme="@android:style/Theme.NoTitleBar" android:versionCode="1" android:versionName="3.0" package="com.mycompany.mygame" android:installLocation="preferExternal">
  <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:smallScreens="true" android:xlargeScreens="true" />
  <application android:icon="@drawable/app_icon" android:label="@string/app_name" android:debuggable="true">
    <activity android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:label="@string/app_name" android:launchMode="singleTask" android:screenOrientation="reverseLandscape" android:name="com.mycompany.mygame.UnityPlayerNativeActivity">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
      <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="false" />
    </activity>
    <activity android:configChanges="keyboardHidden|orientation" android:name="com.facebook.LoginActivity" android:screenOrientation="portrait">
    </activity>
    <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="\ 586438214724597" />
  </application>
  <uses-sdk android:minSdkVersion="9" android:targetSdkVersion="19" />
  <uses-feature android:glEsVersion="0x00020000" />
  <uses-permission android:name="android.permission.INTERNET" />
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
  <uses-feature android:name="android.hardware.touchscreen" />
  <uses-feature android:name="android.hardware.touchscreen.multitouch" android:required="false" />
  <uses-feature android:name="android.hardware.touchscreen.multitouch.distinct" android:required="false" />
</manifest>

两个主要的不同:(1)正确的清单文件中的主要活动被命名为com.facebook.unity.FBUnityPlayerActivity和不正确的文件的com.mycompany.mygame.UnityPlayerNativeActivity,和(2)出现正确的文件也有一个com.unity3d.player.UnityPlayerActivity和com.mycompany.mygame.UnityPlayerNativeActivity之后。

Two main differences: (1) The main activity for the correct manifest file is named "com.facebook.unity.FBUnityPlayerActivity" and for the incorrect file its "com.mycompany.mygame.UnityPlayerNativeActivity", and (2) the correct file also has a "com.unity3d.player.UnityPlayerActivity" and the "com.mycompany.mygame.UnityPlayerNativeActivity" appears after it.

但遗憾的是,大部分的时候,团结是生成文件的版本不正确。我已经与FriendSmash游戏测试了,测试了一个自定义应用程序,增加了Facebook的SDK,并测试另一个示例应用程序仅包含Facebook的SDK(全部在Windows和Mac)。他们都产生了错误版本,除了偶然的机会,我第一次下载了FriendSmash完整的项目。而当我下载FriendSmash新鲜的测试在Mac上,它开始生成文件中不正确也是如此。

But unfortunately, most of the time, Unity is generating the incorrect version of the file. I've tested it with the FriendSmash game, tested a custom app that adds the facebook sdk, and tested another sample app that only contains the facebook SDK (all on both windows and mac). They all generated the wrong version, except by chance, the first time I downloaded the FriendSmash complete project. And when I downloaded FriendSmash fresh to test on mac, it started generating the file incorrectly as well.

此外,如果你只是尝试建立团结的apk文件,而无需创建了谷歌Android项目,它使用了错误的清单,并建立一个破碎的应用程序。

Additionally, if you just try to build the apk file in unity without creating the Google Android Project, it uses the wrong manifest and builds a broken app.

解决方案:
不知道。人对如何解决这一问题的任何想法?

Solution: No Idea. Anyone have any thoughts on how to fix this?

推荐答案

好了,似乎在示例项目的新版本和新的SDK的统一包所提供的清单文件被用来构建自定义清单文件那谷歌Android项目采用。它必须被错误更新,是什么原因造成的问题。

Ok, so it seems the manifest file being provided in the new version of the sample project and in the new SDK unity package are used to build the custom manifest file that the Google Android Project uses. It must have been updated incorrectly and is what is causing the problems.

要解决,你导入Facebook的SDK后,刚刚与旧版本替换为资产/插件/ Android版/ AndroidManifest.xml中的文件:

To fix, after you import the Facebook SDK, just replace the file at Assets/Plugins/Android/AndroidManifest.xml with the old version:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.unity3d.player" android:installLocation="preferExternal" android:theme="@android:style/Theme.NoTitleBar" android:versionCode="1" android:versionName="1.0">
  <supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true" />
  <application android:icon="@drawable/app_icon" android:label="@string/app_name" android:debuggable="true">
    <activity android:name="com.facebook.unity.FBUnityPlayerActivity" android:launchMode="singleTask" android:label="@string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
    </activity>
    <activity android:name="com.unity3d.player.UnityPlayerActivity" android:launchMode="singleTask" android:label="@string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
    </activity>
    <activity android:name="com.unity3d.player.UnityPlayerNativeActivity" android:launchMode="singleTask" android:label="@string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
      <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="false" />
    </activity>
    <activity android:name="com.facebook.LoginActivity" android:screenOrientation="portrait" android:configChanges="keyboardHidden|orientation">
    </activity>
    <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="\ 586438214724597" />
  </application>
</manifest>

我还没有与建设一个新的谷歌Android项目测试这一点,但我能够直接生成APK文件,并在手机上运行。

I haven't yet tested this with building a new Google Android Project, but I was able to directly build the apk file and run it on the phone.

这篇关于Facebook的SDK团结Android的 - 正在生成错误清单文件,无法登陆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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