4

Suddenly when i compile my project in android phone i get this error with the merge of manifest

Execution failed for task ':app:processDebugManifest'. Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91 is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory). Suggestion: add 'tools:replace="android:appComponentFactory"' to element at AndroidManifest.xml:7:5-117 to override.

I try to add in my gradle.properties

android.enableJetifier=true
android.useAndroidX=true

and i get other error

Execution failed for task ':react-native-firebase:compileDebugJavaWithJavac'. Compilation failed; see the compiler error output for details

My manifest

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.wizdeoapptalent">

<uses-permission android:name="android.permission.INTERNET" />

<application
  android:name=".MainApplication"
  android:label="@string/app_name"
  android:icon="@mipmap/ic_launcher"
  android:roundIcon="@mipmap/ic_launcher_round"
  android:allowBackup="false"
  android:theme="@style/AppTheme">
  <activity
    android:name=".MainActivity"
    android:label="@string/app_name"
    android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
    android:windowSoftInputMode="adjustResize">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
  </activity>
  <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
  <service android:name="io.invertase.firebase.messaging.RNFirebaseMessagingService">
      <intent-filter>
          <action android:name="com.google.firebase.MESSAGING_EVENT" />
      </intent-filter>
  </service>
  <service android:name="io.invertase.firebase.messaging.RNFirebaseBackgroundMessagingService" />
</application>

My build.gradle

    // Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 16
        compileSdkVersion = 28
        targetSdkVersion = 28
        supportLibVersion = "28.0.0"
        googlePlayServicesAuthVersion = "15.0.1"
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.1'
        classpath 'com.google.gms:google-services:4.2.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        mavenLocal()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
    }
}

My app/build.gradle

apply plugin: "com.android.application"

import com.android.build.OutputFile

def enableSeparateBuildPerCPUArchitecture = false

/**
 * Run Proguard to shrink the Java bytecode in release builds.
 */
def enableProguardInReleaseBuilds = false

android {
    compileSdkVersion rootProject.ext.compileSdkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
        applicationId "com.wizdeoapptalent"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0"
    }
    signingConfigs {
        release {
            if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
                storeFile file(MYAPP_RELEASE_STORE_FILE)
                storePassword MYAPP_RELEASE_STORE_PASSWORD
                keyAlias MYAPP_RELEASE_KEY_ALIAS
                keyPassword MYAPP_RELEASE_KEY_PASSWORD
            }
        }
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
        }
    }
    buildTypes {
        release {
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            signingConfig signingConfigs.release
        }
    }
    // applicationVariants are e.g. debug, release
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            // For each separate APK per architecture, set a unique version code as described here:
            // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
            def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3, "x86_64": 4]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) {  // null for the universal-debug, universal-release variants
                output.versionCodeOverride =
                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
            }
        }
    }
}

dependencies {
    implementation project(':react-native-i18n')
    implementation project(':react-native-device-info')
    implementation project(':react-native-vector-icons')
    implementation project(':react-native-google-signin')
    implementation project(':react-native-gesture-handler')
    implementation project(':react-native-firebase')
    implementation project(':react-native-device-info')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation "com.google.android.gms:play-services-base:16.1.0"
    implementation "com.google.firebase:firebase-core:16.0.8"
    implementation "com.google.firebase:firebase-messaging:17.5.0"
    implementation 'me.leolin:ShortcutBadger:1.1.21@aar'

}

// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}
apply plugin: 'com.google.gms.google-services'

I don't understand why i get these errors suddenly

UPDATE

I solved this issue with this response after trying all solution provided in comments. Thanks you for all

Tara
  • 2,598
  • 1
  • 21
  • 30
  • tools:replace="android:appComponentFactory" in your main manifest file application tag. – Tara Jun 24 '19 at 08:59
  • This issue is related to Android X, please search with Androidx – Jebin Benny Jun 24 '19 at 09:02
  • @Tara i try "tools:replace="android:appComponentFactory" and i get > Task :app:processDebugManifest FAILED /home/youness/Documents/wizdeoapptalent/android/app/src/main/AndroidManifest.xml:7:5-32:19 Error: tools:replace specified at line:7 for attribute android:appComponentFactory, but no new value specified /home/youness/Documents/wizdeoapptalent/android/app/src/main/AndroidManifest.xml Error: Validation failed, exiting – Youness Chetoui Jun 24 '19 at 09:07
  • @JebinBenny may be more explicit about android X ? – Youness Chetoui Jun 24 '19 at 09:09
  • @YounessChetoui, 1: Update Android Studio Version to. 3.4.1 2: Go to top toolbar -> Refactor -> Migrate to AndroidX -> Migrate 3: After migration complete, 4: Check any error, 5: If found any error, search that library with Android x 6: ReStart project. – Jebin Benny Jun 24 '19 at 09:15
  • tools:replace="android:appComponentFactory" android:appComponentFactory="whateverString" add these 2 lines of code in your application tag. – Tara Jun 24 '19 at 09:17
  • @JebinBenny I update Android studio and when i try to migrate i get message "No usages Found in the project" – Youness Chetoui Jun 24 '19 at 09:26
  • @Tara i get other error after put your solution com.android.build.api.transform.TransformException: Error while generating the main dex list: Error while merging dex archives: Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes. Program type already present: android.support.v4.app.INotificationSideChannel$Stub$Proxy – Youness Chetoui Jun 24 '19 at 09:35
  • @YounessChetoui you have to check with the following link and replace at your node module corresponding to 'react-native-firebase'. https://developer.android.com/jetpack/androidx/migrate – Jebin Benny Jun 24 '19 at 09:46
  • 1
    I solved my issue with this [response](https://stackoverflow.com/a/56674446/9331893) – Youness Chetoui Jun 24 '19 at 09:53

2 Answers2

1

Updating react-native-device-info to v2.1.3 will fix the issue

Vinil Prabhu
  • 1,279
  • 1
  • 10
  • 22
0

see this answer for not upgrading to androidX should prevent it from happening on react native 0.59.X

Manifest merger failed after import a module

mike james
  • 8,840
  • 3
  • 18
  • 21