0

I implemented Facebook SDK

dependencies {
 compile 'com.facebook.android:facebook-android-sdk:4.16.1'
}

And change my my mindSdkVersion from 14 to 15 cause it was said in the document Select API 15: Android 4.0.3 or higher and create your new project.

defaultConfig {
    applicationId "com.myapp.myapplication"
    minSdkVersion 15
    targetSdkVersion 23
    multiDexEnabled true
}

after following the steps I encountered this error Manifest merger failed with multiple errors how to solve this?

*Update

I forgot to app my newly created class that is extended to Application in the Manifest here is my class

public class MyApplication extends Application {

@Override
public void onCreate() {
    super.onCreate();
    // Initialize the SDK before executing any other operations,
    FacebookSdk.sdkInitialize(getApplicationContext());
    AppEventsLogger.activateApp(this);
}
}

and so I added it in my Manifest

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme"
    android:name="com.myapp.myapplication.MyApplication"> 

changing android:name="android.support.multidex.MultiDexApplication" to com.myapp.myapplication.MyApplication

and encountered this

    Error:Execution failed for task ':app:processDebugManifest'.> Manifest merger failed : Attribute activity#com.facebook.FacebookActivity@theme value=(@android:style/Theme.Translucent.NoTitleBar) from AndroidManifest.xml:388:13-72
is also present at [com.facebook.android:facebook-android-sdk:4.16.1] AndroidManifest.xml:32:13-63 value=(@style/com_facebook_activity_theme).
Suggestion: add 'tools:replace="android:theme"' to <activity> element at AndroidManifest.xml:385:13-389:48 to override.
natsumiyu
  • 3,217
  • 7
  • 30
  • 54

2 Answers2

0

In Manifest, I re-arrange the position to

<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"
        android:screenOrientation="portrait"/>

 <provider android:authorities="com.facebook.app.FacebookContentProvider"
        android:name="com.facebook.FacebookContentProvider"
        android:exported="true" />
natsumiyu
  • 3,217
  • 7
  • 30
  • 54
0

Upgrade your Facebook sdk to

implementation 'com.facebook.android:facebook-android-sdk:5.2.0'

and add "android:replace" to your Facebook activity tag like this

<activity android:name="com.facebook.FacebookActivity" android:label="@string/app_name" android:replace="android:theme"/>