Error on application ID of facebook app in Manifest

后端 未结 4 1262
盖世英雄少女心
盖世英雄少女心 2021-01-01 22:44

Here is a little detail about my app. I have a tab layout using Fragments and a ViewPager. On the third tab, I have a Google Map V2. Now, whenever

相关标签:
4条回答
  • 2021-01-01 23:03

    You cannot put the appID directly into the manifest itself, you need to reference a string resource in the manifest. Something like:

    In your AndroidManifest:

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

    In your strings.xml

    <resources>
      ...
      <string name="app_id">$app_id_here</string>
    </resources>
    
    0 讨论(0)
  • 2021-01-01 23:08

    Shouldn't that actually be:

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

    Note the change from android:value to android:resource.

    0 讨论(0)
  • 2021-01-01 23:12

    It is important to bear in mind that you have to paste the meta-data element WITHIN THE APPLICATION TAGS.

    This way:

     <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
    
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    
        <meta-data android:name="com.facebook.sdk.ApplicationId"
            android:value="@string/facebook_app_id"/>
    </application>
    

    If you paste it somewhere else, you will keep getting this error.

    0 讨论(0)
  • 2021-01-01 23:14

    Incase anyone is still having problems with this, here's the solution I found:

    I was still getting a manifest merge error when I made these changes. I noticed that if I changed android:value to android:resource, I could fire off the app but it would still crash when I tried to launch facebook. I found the solution while in the "Merged Manifest" tab at the bottom of the screen when looking at the android Manifest.xml. Code as follows:

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

    Notice the tools:replace="android:value" comes before android:value This is important for the flow and fixed my problem.

    Hope this helps!

    0 讨论(0)
提交回复
热议问题