清单合并失败:<meta-data> com.facebook.sdk.ApplicationId

时间:2019-06-01 13:40:34

标签: android xml facebook facebook-login

我正在尝试为我的Android应用程序实现Facebook登录。因此,我正在关注Facebook提供的快速入门。但是,他们声明元数据的方式对我不起作用,它引发了多个清单合并错误。

我试图在与Facebook登录相关的两个活动中设置元数据。这解决了我的合并错误,但是Facebook无法识别我的AppID。我还尝试使用不同版本的facebook依赖项(“ [5,6)”,“ 5.0.1”,“ 4. +”),甚至在清单的不同位置设置元数据。

Facebook快速入门提供的xml

<meta-data android:name="com.facebook.sdk.ApplicationId" 
        android:value="@string/facebook_app_id"/>

    <activity android:name="com.facebook.FacebookActivity"
        android:configChanges=
                "keyboard|keyboardHidden|screenLayout|screenSize|orientation"
        android:label="@string/app_name" />
    <activity
        android:name="com.facebook.CustomTabActivity"
        android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="@string/fb_login_protocol_scheme" />
        </intent-filter>
    </activity>

我尝试过的方法:没有引发任何错误,但是无法识别AppID

 <activity android:name="com.facebook.FacebookActivity"
        android:configChanges=
        "keyboard|keyboardHidden|screenLayout|screenSize|orientation"
        android:label="@string/app_name"> 
        <meta-data android:name="com.facebook.sdk.ApplicationId" 
        android:value="@string/facebook_app_id"/>
 </activity>
    <activity
        android:name="com.facebook.CustomTabActivity"
        android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="@string/fb_login_protocol_scheme" />
        </intent-filter>
       <meta-data android:name="com.facebook.sdk.ApplicationId" 
        android:value="@string/facebook_app_id"/>
    </activity>

完整应用程序:

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="..."
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme"
    tools:ignore="GoogleAppIndexingWarning">

    <!--
        Facebook API key
    -->

    <meta-data android:name="com.facebook.sdk.ApplicationId"
        android:value="@string/facebook_app_id"/>

    <activity android:name="com.facebook.FacebookActivity"
        android:configChanges=
            "keyboard|keyboardHidden|screenLayout|screenSize|orientation"
        android:label="@string/app_name" />
    <activity
        android:name="com.facebook.CustomTabActivity"
        android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="@string/fb_login_protocol_scheme" />
        </intent-filter>
    </activity>

    <activity
        android:name=".Activities.SettingsActivity"
        android:label="@string/title_activity_settings"
        android:theme="@style/AppTheme.NoActionBar"></activity>
    <activity
        android:name=".Activities.EventPageActivity"
        android:label="@string/title_activity_event_page"
        android:theme="@style/AppTheme.NoActionBar" />

    <uses-library
        android:name="org.apache.http.legacy"
        android:required="false" />

    <activity
        android:name=".Activities.LoginActivity"
        android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".Activities.EventCreation"
        android:theme="@style/Theme.custom.dialog"/>

    <activity android:name=".Activities.MainActivity" />
    <activity android:name=".Activities.EmailAndPasswordConnection" />
    <!--
         The API key for Google Maps-based APIs is defined as a string resource.
         (See the file "res/values/google_maps_api.xml").
         Note that the API key is linked to the encryption key used to sign the APK.
         You need a different API key for each encryption key, including the release key that is used to
         sign the APK for publishing.
         You can define the keys for the debug and release targets in src/debug/ and src/release/. 
    -->
    <meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="..." />

</application>

日志包含947行,因此我不确定是否应该将它们放在此处。

通常它应该起作用,因为它是在Facebook“教程”中进行解释的方式。

有人已经遇到了这个问题,并且知道如何解决吗?

0 个答案:

没有答案