我正在尝试设置Facebook登录权限(" email"),但是我收到此错误:
Xamarin.Facebook.FacebookException:Log in attempt failed:FacebookActivity could not be started. Please make sure you added FacebookActivity to the AdroidManifest.
这是我遇到错误的地方:
// After facebook,google and all identity provider login completed
auth.Completed += async (sender, eventArgs) =>
{
if (eventArgs.IsAuthenticated)
{
try
{
LoginManager.Instance.LogInWithReadPermissions(activity, new string[] { "public_profile", "email", "user_friends" }); //Arrays.asList("public_profile", "email"));
}
catch(Exception ex)
{
await App.Current.MainPage.DisplayAlert("ERROR!!!", ex.ToString(), ":(");
}
我已经定义了我的Android清单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="LoginSystem.Android">
<!--suppress UsesMinSdkAttributes-->
<uses-sdk android:minSdkVersion="15" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.email" />
<application android:label="LoginSystem.Android" android:name="android.app.Application" android:allowBackup="true" android:icon="@drawable/icon" android:debuggable="true">
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id" />
<activity android:configChanges="orientation|screenSize" android:icon="@drawable/icon" android:label="LoginSystem" android:theme="@style/MainTheme" android:name="md50ef850b548eeb6d8287c9a52e2084363.MainActivity" />
<activity android:noHistory="true" android:theme="@style/Theme.Splash" android:name="md50ef850b548eeb6d8287c9a52e2084363.SplashActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:label="Intervention-X">
</activity>
<service android:name="md59f70a99687498e7ba187118950981d26.KeepAliveService" />
<activity android:label="Web Authenticator" android:name="md550f8a10a740eb4fb6376baab8337ce22.FormAuthenticatorActivity" />
<activity android:label="Web Authenticator" android:name="md550f8a10a740eb4fb6376baab8337ce22.WebAuthenticatorActivity" />
<activity android:name="md511f2fcf685a3847eee0baf2c814b548d.MediaPickerActivity" />
<provider android:name="mono.MonoRuntimeProvider" android:exported="false" android:initOrder="2147483647" android:authorities="LoginSystem.Android.mono.MonoRuntimeProvider.__mono_init__" />
<!--suppress ExportedReceiver-->
<receiver android:name="mono.android.Seppuku">
<intent-filter>
<action android:name="mono.android.intent.action.SEPPUKU" />
<category android:name="mono.android.intent.category.SEPPUKU.LoginSystem.Android" />
</intent-filter>
</receiver>
</application>
<activity android:name="com.facebook.FacebookActivity" android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation" android:theme="@android:style/Theme.Translucent.NoTitleBar" android:label="@string/app_name" />
<meta-data android:name="android.support.VERSION" android:value="25.3.1" />
</manifest>
另外,由于某种原因,我有2个Manifest.xml
个文件。不知道我刚刚附上的那个的位置,但原来的位置在原来的位置(在属性下),它看起来像这样:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-sdk android:minSdkVersion="15" />
<application android:label="LoginSystem.Android">
</application>
<activity android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:label="Intervention-X" />
</manifest>