Nativescript-plugin-firebase: Errors since latest Google Firebase update ("Manifest merger failed")

Created on 18 Jun 2019  路  18Comments  路  Source: EddyVerbruggen/nativescript-plugin-firebase

Google released a new version of Firebase yesterday:

https://developers.google.com/android/guides/releases#june_17_2019

However, since this, whether I'm using v9.0.0 or v8.3.2 (or the just released v9.0.1) I am getting the following error:

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 <application> element at AndroidManifest.xml:18:2-31:16 to override.

People using React Native have been having the same issue over the last 24 hours, and one solution suggests pinning the Firebase version.

Perhaps this needs to be done within this plugin?

Here is my app.gradle:

android {
  defaultConfig {
    // Fix for: The number of method references in a .dex file cannot exceed 64K.
    // (see: https://developer.android.com/tools/building/multidex.html)
    multiDexEnabled true
    minSdkVersion 17
    generatedDensities = []
  }
  aaptOptions {
    additionalParameters "--no-version-vectors"
  }
}

project.ext {
  googlePlayServicesVersion = "15.0.0"
}

dependencies {
  def googlePlayServicesVersion = project.googlePlayServicesVersion
  compile "com.google.android.gms:play-services-base:$googlePlayServicesVersion"
  compile "com.google.android.gms:play-services-location:$googlePlayServicesVersion"
}
def settingsGradlePath

if(project.hasProperty("appResourcesPath")){
    settingsGradlePath = "$project.appResourcesPath/Android/settings.gradle";
} else {
    settingsGradlePath = "$rootDir/../../app/App_Resources/Android/settings.gradle";
}

def settingsGradleFile = new File(settingsGradlePath);

if(settingsGradleFile.exists())
{
    apply from: settingsGradleFile;
}

Many thanks

Most helpful comment

I too faced the same issue @joshcomley . But I managed to resolve it by setting the googlePlayServicesVersion to 15.0.+

project.ext {
  googlePlayServicesVersion = "15.0.+"
}

All 18 comments

In case anyone else has this problem, I fixed this by moving my support dependencies into before-plugins.gradle, which now looks like this:

project.ext {
  googlePlayServicesVersion = "15.0.0"
}

dependencies {
  compile 'com.squareup.picasso:picasso:2.71828'
  def googlePlayServicesVersion = project.googlePlayServicesVersion
  compile "com.google.android.gms:play-services-base:$googlePlayServicesVersion"
  compile "com.google.android.gms:play-services-location:$googlePlayServicesVersion"
  def supportVer = "28.0.0"
  compile "com.android.support:support-v4:$supportVer"
  compile "com.android.support:appcompat-v7:$supportVer"
  compile "com.android.support:design:$supportVer"
}

No idea why they suddenly needed to be moved, but hey ho!

I too faced the same issue @joshcomley . But I managed to resolve it by setting the googlePlayServicesVersion to 15.0.+

project.ext {
  googlePlayServicesVersion = "15.0.+"
}

I'm having this issue too, none of the suggestions above seem to work for me, this is my app.gradle that's in app/App_Resources/Android

// Add your native dependencies here:

// Uncomment to add recyclerview-v7 dependency
//dependencies {
//  compile 'com.android.support:recyclerview-v7:+'
//}

android {
  defaultConfig {
    generatedDensities = []
    applicationId = "com.***.***"

    //override supported platforms
    // ndk {
    //       abiFilters.clear()
    //          abiFilters "armeabi-v7a"
        // }


  }
  aaptOptions {
    additionalParameters "--no-version-vectors"
  }



  project.ext {
    googlePlayServicesVersion = "15.0.+"
  }

}

Hi @arielnmz, have you tried moving the following code segment to before-plugins.gradle?

project.ext {
  googlePlayServicesVersion = "15.0.+"
}

@benedictkhoo Sorry never occured to me that I had to clean the environment before rebuilding, putting that in before-plugins.gradle does solve it. Thank you!

@arielnmz awesome! Glad to hear it!

hey i cant find where this before-plugins.gradle file is located please help me out @joshcomley @benedictkhoo

Hi @oo7Holmes, you will need to create it if it doesn't exist.

Hi @oo7Holmes, you will need to create it if it doesn't exist.

Where go that file?

hi @davidcort , you will need to create the before-plugins.gradle file if it does not exist. It should be created within the same folder as app.gradle.

Hi, I moved my dependencies to the before-plugin.gradle file but now my MainActivity.java file became red on certain areas.

Android resource linking failed error: resource style/Theme.AppCompat.Light.DarkActionBar (aka com.example.ibm2105_cw2_source_g15:style/Theme.AppCompat.Light.DarkActionBar) not found. C:\Users\Javelin\AndroidStudioProjects\IBM2105_CW2_Source_G15\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:17: error: style attribute 'attr/colorPrimary (aka com.example.ibm2105_cw2_source_g15:attr/colorPrimary)' not found. C:\Users\Javelin\AndroidStudioProjects\IBM2105_CW2_Source_G15\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:18: error: style attribute 'attr/colorPrimaryDark (aka com.example.ibm2105_cw2_source_g15:attr/colorPrimaryDark)' not found. C:\Users\Javelin\AndroidStudioProjects\IBM2105_CW2_Source_G15\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:19: error: style attribute 'attr/colorAccent (aka com.example.ibm2105_cw2_source_g15:attr/colorAccent)' not found. error: failed linking references.

Hi @JavelinYu , mind sharing your before-plugin.gradle content?

project.ext {
googlePlayServicesVersion = "15.0.+"
}

dependencies {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.firebase:firebase-core:17.0.0'
}
}

Hi @JavelinYu , for the before-plugin.gradle file, you will only need the following:

project.ext {
  googlePlayServicesVersion = "15.0.+"
}

The rest should remain in app.gradle.

I moved it back but now it shows back the initial error message:

ERROR: 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:5:5-19:19 to override.

Here's my app.gradle codes:
apply plugin: 'com.android.application'

android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.ibm2105_cw2_source_g15"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.google.firebase:firebase-core:17.0.0'
}

apply plugin: 'com.google.gms.google-services'

Hi @JavelinYu , can you try to clean your platform folders using the tns platform clean command? You can refer to this site (https://docs.nativescript.org/tooling/docs-cli/project/configuration/platform-clean) for more details. After that is done, you may want to try to run your app again.

I saw 'picasso' in one of the errors mentioned here. That was fixed in the Firebase Android SDK that's bundled with plugin version 9.1.0. So please upgrade to that, and make sure to clean the platforms/node_modules folders when doing so.

So what should the app.gradle and before-plugins.gradle files look like because I'm still getting this error and Android won't run.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ButterMeWaffle picture ButterMeWaffle  路  4Comments

NickIliev picture NickIliev  路  3Comments

vchimev picture vchimev  路  3Comments

thunder413 picture thunder413  路  3Comments

WaseemAhmadZ picture WaseemAhmadZ  路  3Comments