将 Facebook 插件与 Unity 一起使用时出现 ActivityNotFoundException
ActivityNotFoundException when using Facebook plugin with Unity
我正在使用 Unity 5.2.2p2、Facebook Unity SDK 7.2.2 和 Prime31 的 Android IAB 插件 2.9。当我编译我的应用程序并在设备上 运行 时,在 adb 日志中我看到:
I/Unity (18149): AndroidJavaException: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.-----.----/com.facebook.unity.FBUnityLoginActivity}; have you declared this activity in your AndroidManifest.xml?
I/Unity (18149): at UnityEngine.AndroidJNISafe.CheckException () [0x00000] in <filename unknown>:0
I/Unity (18149): at UnityEngine.AndroidJNISafe.CallStaticVoidMethod (IntPtr clazz, IntPtr methodID, UnityEngine.jvalue[] args) [0x00000] in <filename unknown>:0
I/Unity (18149): at UnityEngine.AndroidJavaObject._CallStatic (System.String methodName, System.Object[] args) [0x00000] in <filename unknown>:0
I/Unity (18149): at UnityEngine.AndroidJavaObject.CallStatic (System.String methodName, System.Object[] args) [0x00000] in <filename unknown>:0
I/Unity (18149): at Facebook.Unity.Mobile.Android.FBJavaClass.CallStatic (System.String methodName, System.Object[] args) [0x00000] in <filename unknown>:0
I/Unity (18149): at Facebook.Unity.Mobile.Android.AndroidFacebook.CallFB (System.String method, System.String args) [0x00000] in <filename unknown>:0
I/Unity (18149): at Facebook.Unity.
但是在 Assets/Plugins/Android/AndroidManifest.xml 文件中,我有以下定义:
<activity android:configChanges="locale|fontScale|keyboard|keyboardHidden|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode" android:label="@string/app_name" android:launchMode="singleTask" android:name="com.unity3d.player.UnityPlayerActivity" android:screenOrientation="sensorLandscape">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<category android:name="android.intent.category.LEANBACK_LAUNCHER"/>
</intent-filter>
<meta-data android:name="unityplayer.UnityActivity" android:value="true"/>
</activity>
<activity android:configChanges="locale|fontScale|keyboard|keyboardHidden|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode" android:name="com.facebook.unity.FBUnityLoginActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"/>
<activity android:configChanges="locale|fontScale|keyboard|keyboardHidden|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode" android:name="com.facebook.unity.FBUnityDialogsActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"/>
<activity android:configChanges="keyboardHidden|orientation" android:name="com.facebook.LoginActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"/>
<activity android:exported="true" android:name="com.facebook.unity.FBUnityAppLinkActivity"/>
<activity android:exported="true" android:name="com.facebook.unity.FBUnityDeepLinkingActivity"/>
<activity android:name="com.facebook.unity.FBUnityGameRequestActivity"/>
<activity android:name="com.facebook.unity.FBUnityCreateGameGroupActivity"/>
<activity android:name="com.facebook.unity.FBUnityJoinGameGroupActivity"/>
<activity android:name="com.facebook.unity.AppInviteDialogActivity"/>
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="fb1234removed"/>
<provider android:authorities="com.facebook.app.FacebookContentProvider1234removed" android:exported="true" android:name="com.facebook.FacebookContentProvider"/>
<activity android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize" android:label="@string/app_name" android:name="com.facebook.FacebookActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar"/>
<activity android:configChanges="keyboard|keyboardHidden|layoutDirection|orientation|screenLayout|screenSize|uiMode" android:name="com.prime31.GoogleIABProxyActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"/>
这对我来说毫无意义。这曾经有效,但我不确定为什么不再有效。
只想回答我已经设法修复它。这是 Unity 的事情之一,你只需要卸载所有插件并重新安装它们。找到与这两个插件相关的每个文件,删除它们,然后一次安装一个。
此外,随着 2.9 中新的 Smoola
集成,如果您不使用 Smoola,插件无论如何都会加载并检查互联网访问。这需要 Prime31
清单不包含的 ACCESS_NETWORK_STATE
权限。
我正在使用 Unity 5.2.2p2、Facebook Unity SDK 7.2.2 和 Prime31 的 Android IAB 插件 2.9。当我编译我的应用程序并在设备上 运行 时,在 adb 日志中我看到:
I/Unity (18149): AndroidJavaException: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.-----.----/com.facebook.unity.FBUnityLoginActivity}; have you declared this activity in your AndroidManifest.xml?
I/Unity (18149): at UnityEngine.AndroidJNISafe.CheckException () [0x00000] in <filename unknown>:0
I/Unity (18149): at UnityEngine.AndroidJNISafe.CallStaticVoidMethod (IntPtr clazz, IntPtr methodID, UnityEngine.jvalue[] args) [0x00000] in <filename unknown>:0
I/Unity (18149): at UnityEngine.AndroidJavaObject._CallStatic (System.String methodName, System.Object[] args) [0x00000] in <filename unknown>:0
I/Unity (18149): at UnityEngine.AndroidJavaObject.CallStatic (System.String methodName, System.Object[] args) [0x00000] in <filename unknown>:0
I/Unity (18149): at Facebook.Unity.Mobile.Android.FBJavaClass.CallStatic (System.String methodName, System.Object[] args) [0x00000] in <filename unknown>:0
I/Unity (18149): at Facebook.Unity.Mobile.Android.AndroidFacebook.CallFB (System.String method, System.String args) [0x00000] in <filename unknown>:0
I/Unity (18149): at Facebook.Unity.
但是在 Assets/Plugins/Android/AndroidManifest.xml 文件中,我有以下定义:
<activity android:configChanges="locale|fontScale|keyboard|keyboardHidden|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode" android:label="@string/app_name" android:launchMode="singleTask" android:name="com.unity3d.player.UnityPlayerActivity" android:screenOrientation="sensorLandscape">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<category android:name="android.intent.category.LEANBACK_LAUNCHER"/>
</intent-filter>
<meta-data android:name="unityplayer.UnityActivity" android:value="true"/>
</activity>
<activity android:configChanges="locale|fontScale|keyboard|keyboardHidden|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode" android:name="com.facebook.unity.FBUnityLoginActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"/>
<activity android:configChanges="locale|fontScale|keyboard|keyboardHidden|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode" android:name="com.facebook.unity.FBUnityDialogsActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"/>
<activity android:configChanges="keyboardHidden|orientation" android:name="com.facebook.LoginActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"/>
<activity android:exported="true" android:name="com.facebook.unity.FBUnityAppLinkActivity"/>
<activity android:exported="true" android:name="com.facebook.unity.FBUnityDeepLinkingActivity"/>
<activity android:name="com.facebook.unity.FBUnityGameRequestActivity"/>
<activity android:name="com.facebook.unity.FBUnityCreateGameGroupActivity"/>
<activity android:name="com.facebook.unity.FBUnityJoinGameGroupActivity"/>
<activity android:name="com.facebook.unity.AppInviteDialogActivity"/>
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="fb1234removed"/>
<provider android:authorities="com.facebook.app.FacebookContentProvider1234removed" android:exported="true" android:name="com.facebook.FacebookContentProvider"/>
<activity android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize" android:label="@string/app_name" android:name="com.facebook.FacebookActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar"/>
<activity android:configChanges="keyboard|keyboardHidden|layoutDirection|orientation|screenLayout|screenSize|uiMode" android:name="com.prime31.GoogleIABProxyActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"/>
这对我来说毫无意义。这曾经有效,但我不确定为什么不再有效。
只想回答我已经设法修复它。这是 Unity 的事情之一,你只需要卸载所有插件并重新安装它们。找到与这两个插件相关的每个文件,删除它们,然后一次安装一个。
此外,随着 2.9 中新的 Smoola
集成,如果您不使用 Smoola,插件无论如何都会加载并检查互联网访问。这需要 Prime31
清单不包含的 ACCESS_NETWORK_STATE
权限。