Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Manifest merger failed. After adding and linking react-native-device-info

Tags:

Manifest merger failed : Attribute meta-data#android.support.VERSION@value value=(26.0.1) from [com.android.support:cardview-v7:25.3.1] AndroidManifest.xml:24:9-31 is also present at [com.android.support:support-v4:26.1.0] AndroidManifest.xml:28:13-35 value=(26.1.0). Suggestion: add 'tools:replace="android:value"' to element at AndroidManifest.xml:26:9-28:38 to override.

RN v0.55

react-native-device-info v0.21.5

app/build.gradle:

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.1"
    defaultConfig {
        applicationId "com.myapp"
        minSdkVersion 18
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86"
        }
    }
}
dependencies {
    compile project(':react-native-device-info')
    compile project(':react-native-splash-screen')
    compile(project(":react-native-google-sign-in")) { //ForGoogleSignIn
        exclude group: "com.google.android.gms"
    }
    compile project(':react-native-fbsdk-corrected')
    compile project(':react-native-vector-icons')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:26.0.1"
   compile "com.facebook.android:facebook-android-sdk:4.28.0"
    compile "com.facebook.react:react-native:+"  
    compile "com.google.android.gms:play-services-auth:11.8.0" 
}

AndroidMenifest:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="com.myapp" xmlns:tools="http://schemas.android.com/tools"
>
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
    <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
    <application
      android:name=".MainApplication"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:allowBackup="true"
      android:theme="@style/AppTheme">
       <activity
        android:name=".SplashActivity"
        android:theme="@style/SplashTheme"
        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=".MainActivity"
        android:label="@string/app_name"
        android:screenOrientation="portrait"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
        android:windowSoftInputMode="adjustResize"
        android:exported="true">
      </activity>
      <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
       <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>

    </application>
</manifest>

react-native-device-info/android/build.gradle

apply plugin: 'com.android.library'

def DEFAULT_COMPILE_SDK_VERSION             = 23
def DEFAULT_BUILD_TOOLS_VERSION             = "25.0.2"
def DEFAULT_TARGET_SDK_VERSION              = 22
def DEFAULT_GOOGLE_PLAY_SERVICES_VERSION    = "+"

android {
    compileSdkVersion project.hasProperty('compileSdkVersion') ? project.compileSdkVersion : DEFAULT_COMPILE_SDK_VERSION
    buildToolsVersion project.hasProperty('buildToolsVersion') ? project.buildToolsVersion : DEFAULT_BUILD_TOOLS_VERSION

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion project.hasProperty('targetSdkVersion') ? project.targetSdkVersion : DEFAULT_TARGET_SDK_VERSION
        versionCode 2
        versionName "1.1"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }
    lintOptions {
       warning 'InvalidPackage'
    }
}

dependencies {
    def googlePlayServicesVersion = project.hasProperty('googlePlayServicesVersion') ? project.googlePlayServicesVersion : DEFAULT_GOOGLE_PLAY_SERVICES_VERSION

    compile 'com.facebook.react:react-native:+'
    compile "com.google.android.gms:play-services-gcm:$googlePlayServicesVersion"
}
like image 703
Imran Noor Avatar asked May 24 '18 08:05

Imran Noor


People also ask

How to check merged manifest?

Even before you build your app, you can see a preview of what your merged manifest looks by opening your AndroidManifest. xml file in Android Studio, and then clicking the Merged Manifest tab at the bottom of the editor.

What is merged manifest?

Android Merged Manifest Merge Manifest feature allows you to check how the final manifest file will looks like. Every module, dependency etc. has it's own AndroidManifest file which is merged in compile time into single one.


1 Answers

Check the build.gradle of the dependent react-native-xxxx module and change the dependent gms andfirebase library's versions to the same.

The version of the gms library that is dependent on your app is currently 11.8.0, so change everything else to 11.8.0.

Check all modules to see the versions of gms andfirebase.

In some cases you may need to change the sdk versions of the react-native-device-info module. Since there are so many cases, write down my settings first.

app/build.gradle:

dependencies {
    // ...
    // gms version is 11.8.0
    compile "com.google.android.gms:play-services-auth:11.8.0" 
}

react-native-device-info/build.gradle: (It's my settings..)

buildscript {
    // set up the same version
    ext.firebaseVersion = '11.8.0'
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'
    }
}

apply plugin: 'com.android.library'

android {
    compileSdkVersion 23
    buildToolsVersion "25.0.2"

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 22
        versionCode 2
        versionName "1.1"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }
    lintOptions {
        abortOnError false
        warning 'InvalidPackage'
    }
}

dependencies {
    compile 'com.facebook.react:react-native:+'
    compile "com.google.android.gms:play-services-gcm:$firebaseVersion"
    compile "com.google.firebase:firebase-core:$firebaseVersion"
    compile "com.google.firebase:firebase-config:$firebaseVersion"
    compile "com.google.firebase:firebase-auth:$firebaseVersion"
    compile "com.google.firebase:firebase-database:$firebaseVersion"
    compile "com.google.firebase:firebase-storage:$firebaseVersion"
    compile "com.google.firebase:firebase-messaging:$firebaseVersion"
    compile "com.google.firebase:firebase-crash:$firebaseVersion"
    compile "com.google.firebase:firebase-perf:$firebaseVersion"
    compile "com.google.firebase:firebase-ads:$firebaseVersion"
    compile "com.google.firebase:firebase-firestore:$firebaseVersion"
    compile "com.google.firebase:firebase-invites:$firebaseVersion"
}
like image 184
UNW Avatar answered Sep 28 '22 19:09

UNW