invertase / react-native-firebase

🔥 A well-tested feature-rich modular Firebase implementation for React Native. Supports both iOS & Android platforms for all Firebase services.
https://rnfirebase.io
Other
11.63k stars 2.2k forks source link

[Android] Error:Failed to notify dependency resolution listener. The library com.google.android.gms:play-services-measurement-api is being requested by various other libraries at [[16.0.4,16.0.4]], but resolves to 16.0.2. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies. #1789

Closed taichi-jp closed 5 years ago

taichi-jp commented 5 years ago

Issue

My project fails to Gradle sync with the error message in the title. When I change the com.google.gms:google-services version to 4.2.0 , I encounter this issue: https://github.com/Microsoft/react-native-code-push/issues/1448 . And the only way to fix that issue is to set com.google.gms:google-services version to 4.1.0 . So I want to fix this issue with com.google.gms:google-services version being 4.1.0 .

The output of ./gradlew :app:dependencies is this (file size is big): gradle_dep.txt


Project Files

iOS

ios/Podfile:

# N/A

AppDelegate.m:

// N/A

Android

android/build.gradle:

buildscript {
    repositories {
        google()
        mavenLocal()
        mavenCentral()
        jcenter()
        maven { url 'https://artifactory.img.ly/artifactory/imgly' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.0'
        classpath 'com.google.gms:google-services:4.1.0'
        classpath 'ly.img.android.pesdk:plugin:6.1.3'

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

allprojects {
    repositories {
        // google maven should be last resort
        google()
        mavenCentral()
        mavenLocal()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
        // jitpack should be last resort
        // ref https://github.com/jitpack/jitpack.io/issues/1939
        maven { url "https://jitpack.io" }
    }
}

// NOTE: https://wix.github.io/react-native-navigation/v2/#/docs/Installing?id=_82-ignore-other-rnn-flavors
subprojects { subproject ->
    afterEvaluate {
        if ((subproject.plugins.hasPlugin('android') || subproject.plugins.hasPlugin('android-library'))) {
            android {
                variantFilter { variant ->
                    def names = variant.flavors*.name
                    if (names.contains("reactNative51") || names.contains("reactNative56")) {
                        setIgnore(true)
                    }
                }
            }
        }
    }
}

// N/A

android/app/build.gradle:

apply plugin: "com.android.application"
apply plugin: 'ly.img.android.pesdk'

import com.android.build.OutputFile

project.ext.react = [
    entryFile: "index.js"
]

project.ext.envConfigFiles = [
        dev: ".env.dev",
        beta: ".env.beta",
        prod: ".env.prod",
]

apply from: "../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"
apply from: "../../node_modules/react-native-sentry/sentry.gradle"
apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"

/**
 * Set this to true to create two separate APKs instead of one:
 *   - An APK that only works on ARM devices
 *   - An APK that only works on x86 devices
 * The advantage is the size of the APK is reduced by about 4MB.
 * Upload all the APKs to the Play Store and people will download
 * the correct one based on the CPU architecture of their device.
 */
def enableSeparateBuildPerCPUArchitecture = false

/**
 * Run Proguard to shrink the Java bytecode in release builds.
 * When enable Proguard, See https://github.com/adjust/react_native_sdk#proguard-settings
 */
def enableProguardInReleaseBuilds = false

pesdkConfig {

    licencePath "pesdk_android_license" // Name of the Licence file in the asset folder

    // Insert the latest SDK version here. You will find it here https://github.com/imgly/pesdk-android-demo/releases
    pesdkVersion "6.1.3"

    // If you use another supportLibVersion ('com.android.support'), change this version here to update your own supportLibVersion
    supportLibVersion "27.1.1"

    // Define the modules you are need
    modules {
        // Add all the backend modules you need
        include 'ly.img.android.pesdk.operation:text'
        include 'ly.img.android.pesdk.operation:frame'
        include 'ly.img.android.pesdk.operation:focus'
        include 'ly.img.android.pesdk.operation:brush'
        include 'ly.img.android.pesdk.operation:camera'
        include 'ly.img.android.pesdk.operation:filter'
        include 'ly.img.android.pesdk.operation:sticker'
        include 'ly.img.android.pesdk.operation:overlay'
        include 'ly.img.android.pesdk.operation:adjustment'
        include 'ly.img.android.pesdk.operation:text-design'
        include 'ly.img.android.pesdk.operation:abstract-sticker'

        // Add all the UI modules you are need
        include 'ly.img.android.pesdk.ui.mobile_ui:core'
        include 'ly.img.android.pesdk.ui.mobile_ui:text'
        include 'ly.img.android.pesdk.ui.mobile_ui:focus'
        include 'ly.img.android.pesdk.ui.mobile_ui:frame'
        include 'ly.img.android.pesdk.ui.mobile_ui:brush'
        include 'ly.img.android.pesdk.ui.mobile_ui:filter'
        include 'ly.img.android.pesdk.ui.mobile_ui:camera'
        include 'ly.img.android.pesdk.ui.mobile_ui:sticker'
        include 'ly.img.android.pesdk.ui.mobile_ui:overlay'
        include 'ly.img.android.pesdk.ui.mobile_ui:transform'
        include 'ly.img.android.pesdk.ui.mobile_ui:adjustment'
        include 'ly.img.android.pesdk.ui.mobile_ui:text-design'

        // Add the serializer if you need
        include 'ly.img.android.pesdk:serializer'

        // Add asset packs if you need
        include 'ly.img.android.pesdk.assets:font-basic'
        include 'ly.img.android.pesdk.assets:font-text-design'
        include 'ly.img.android.pesdk.assets:frame-basic'
        include 'ly.img.android.pesdk.assets:filter-basic'
        include 'ly.img.android.pesdk.assets:overlay-basic'
        include 'ly.img.android.pesdk.assets:sticker-shapes'
        include 'ly.img.android.pesdk.assets:sticker-emoticons'
    }
}

android {
    flavorDimensions "default"
    compileSdkVersion 27

    defaultConfig {
        applicationId "com.foo"
        minSdkVersion 21
        targetSdkVersion 27
        versionCode 47
        versionName "1.4.1"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
        // ref: https://github.com/luggit/react-native-config#advanced-android-setup
        resValue "string", "build_config_package", "com.foo"
        missingDimensionStrategy "RNN.reactNativeVersion", "reactNative55"
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86"
        }
    }
    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]
            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
            }
        }
    }
    dexOptions {
        jumboMode true
    }
}

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support' && requested.name != 'multidex') {
            details.useVersion "27.1.1"
        }
    }
}

dependencies {
    implementation project(':react-native-firebase')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation project(':react-native-fs')
    implementation project(':merryjs-photo-viewer')
    implementation project(':react-native-navigation')
    implementation project(':react-native-custom-tabs')
    implementation project(':react-native-adjust')
    implementation project(':react-native-mixpanel')
    implementation project(':react-native-android-open-settings')
    implementation project(':react-native-haptic-feedback')
    implementation project(':react-native-linear-gradient')
    implementation project(':react-native-code-push')
    implementation project(':react-native-device-info')
    implementation project(':react-native-sentry')
    implementation project(':react-native-fcm')
    implementation project(':react-native-fast-image')
    implementation project(':react-native-image-picker')
    implementation project(':react-native-config')
    implementation project(':react-native-sensitive-info')
    implementation "com.google.android.gms:play-services-base:16.0.1"
    implementation 'com.google.android.gms:play-services-analytics:16.0.4'
    implementation 'com.android.installreferrer:installreferrer:1.0'
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation 'com.twitter.sdk.android:twitter:3.1.1'
    implementation 'com.twitter.sdk.android:twitter-core:3.0.0'
    implementation 'com.google.firebase:firebase-core:16.0.6'
    implementation 'com.google.firebase:firebase-messaging:17.3.4'
    implementation 'com.google.firebase:firebase-inappmessaging-display:17.0.4'
}

// 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'
// N/A

android/settings.gradle:

rootProject.name = 'foo'
include ':react-native-firebase'
project(':react-native-firebase').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-firebase/android')
include ':react-native-fs'
project(':react-native-fs').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fs/android')
include ':app'
include ':react-native-custom-tabs'
project(':react-native-custom-tabs').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-custom-tabs/android')
include ':react-native-adjust'
project(':react-native-adjust').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-adjust/android')
include ':react-native-android-open-settings'
project(':react-native-android-open-settings').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-android-open-settings/android')
include ':react-native-haptic-feedback'
project(':react-native-haptic-feedback').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-haptic-feedback/android')
include ':react-native-linear-gradient'
project(':react-native-linear-gradient').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-linear-gradient/android')
include ':react-native-code-push'
project(':react-native-code-push').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-code-push/android/app')
include ':react-native-device-info'
project(':react-native-device-info').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-device-info/android')
include ':react-native-sentry'
project(':react-native-sentry').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sentry/android')
include ':react-native-fcm'
project(':react-native-fcm').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fcm/android')
include ':react-native-image-picker'
project(':react-native-image-picker').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-image-picker/android')
include ':react-native-config'
project(':react-native-config').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-config/android')
include ':react-native-sensitive-info'
project(':react-native-sensitive-info').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sensitive-info/android')
include ':react-native-mixpanel'
project(':react-native-mixpanel').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-mixpanel/android')
include ':react-native-fast-image'
project(':react-native-fast-image').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fast-image/android')
include ':react-native-navigation'
project(':react-native-navigation').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-navigation/lib/android/app/')
include ':merryjs-photo-viewer'
project(':merryjs-photo-viewer').projectDir = new File(rootProject.projectDir,  '../node_modules/@merryjs/photo-viewer/android')
// N/A

MainApplication.java:

package com.foo;

import android.app.Application;
import android.util.Log;

import com.facebook.react.ReactApplication;
import io.invertase.firebase.RNFirebasePackage;

import com.foo.PESDKPackage;
import com.foo.TwitterPackage;
import com.rnfs.RNFSPackage;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.soloader.SoLoader;

import com.reactnativenavigation.NavigationApplication;
import com.reactnativenavigation.react.NavigationReactNativeHost;
import com.reactnativenavigation.react.ReactGateway;

import com.twitter.sdk.android.core.Twitter;
import com.twitter.sdk.android.core.TwitterConfig;
import com.twitter.sdk.android.core.TwitterAuthConfig;
import com.twitter.sdk.android.core.DefaultLogger;

import com.github.droibit.android.reactnative.customtabs.CustomTabsPackage;
import com.adjust.nativemodule.AdjustPackage;
import com.levelasquez.androidopensettings.AndroidOpenSettingsPackage;
import com.reactlibrary.RNReactNativeHapticFeedbackPackage;
import com.BV.LinearGradient.LinearGradientPackage;
import com.microsoft.codepush.react.CodePush;
import com.learnium.RNDeviceInfo.RNDeviceInfo;
import io.sentry.RNSentryPackage;
import com.evollu.react.fcm.FIRMessagingPackage;
import com.imagepicker.ImagePickerPackage;
import com.lugg.ReactNativeConfig.ReactNativeConfigPackage;
import br.com.classapp.RNSensitiveInfo.RNSensitiveInfoPackage;
import com.kevinejohn.RNMixpanel.*;
import com.dylanvann.fastimage.FastImageViewPackage;
import com.merryjs.PhotoViewer.MerryPhotoViewPackage;

import java.util.Arrays;
import java.util.List;
import ly.img.android.PESDK;

public class MainApplication extends NavigationApplication {
    @Override
    protected ReactGateway createReactGateway() {
        ReactNativeHost host = new NavigationReactNativeHost(this, isDebug(), createAdditionalReactPackages()) {
            @javax.annotation.Nullable
            @Override
            protected String getJSBundleFile() {
                return CodePush.getJSBundleFile();
            }

            @Override
            protected String getJSMainModuleName() {
              return "index";
            }
        };
        return new ReactGateway(this, isDebug(), host);
    }

    @Override
    public boolean isDebug() {
        return BuildConfig.DEBUG;
    }

    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
        new RNMixpanel(),
        new MainReactPackage(),
            new RNFirebasePackage(),
        new RNFSPackage(),
        new CustomTabsPackage(),
        new AdjustPackage(),
        new AndroidOpenSettingsPackage(),
        new RNReactNativeHapticFeedbackPackage(),
        new LinearGradientPackage(),
        new CodePush(getResources().getString(R.string.reactNativeCodePush_androidDeploymentKey), getApplicationContext(), BuildConfig.DEBUG),
        new RNDeviceInfo(),
        new RNSentryPackage(MainApplication.this),
        new FIRMessagingPackage(),
        new ImagePickerPackage(),
        new ReactNativeConfigPackage(),
        new RNSensitiveInfoPackage(),
        new FastImageViewPackage(),
        new TwitterPackage(),
        new PESDKPackage(),
        new MerryPhotoViewPackage()
      );
    }

    @Override
    public List<ReactPackage> createAdditionalReactPackages() {
        return getPackages();
    }

  @Override
  public void onCreate() {
    super.onCreate();
    SoLoader.init(this, /* native exopackage */ false);
    TwitterConfig config = new TwitterConfig.Builder(this)
      .logger(new DefaultLogger(Log.DEBUG))
      .twitterAuthConfig(new TwitterAuthConfig("siwyMK7nDidYEBtQcDf2syG3K", "KazIK1L8aSR04nJCX7BnvHujNXnLeehiRIYPqMzOegLzmaagcw"))
      .debug(true)
      .build();
    Twitter.initialize(this);
    Fresco.initialize(this);
  }
}

// N/A

AndroidManifest.xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.foo"
    android:versionCode="47"
    android:versionName="1.4.1">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-feature android:name="android.hardware.camera" android:required="false"/>
    <uses-feature android:name="android.hardware.camera.autofocus" android:required="false"/>

    <application
      android:name=".MainApplication"
      android:allowBackup="true"
      android:label="${appName}"
      android:icon="@mipmap/ic_launcher"
      android:theme="@style/AppTheme"
      android:largeHeap="true"
      tools:replace="android:label">

      <meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@mipmap/ic_notification"/>
        <receiver android:name="com.evollu.react.fcm.FIRLocalMessagingPublisher"/>
        <receiver android:enabled="true" android:exported="true"  android:name="com.evollu.react.fcm.FIRSystemBootEventReceiver">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED"/>
                <action android:name="android.intent.action.QUICKBOOT_POWERON"/>
                <action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </receiver>

      <service android:name="com.evollu.react.fcm.MessagingService" android:enabled="true" android:exported="true">
       <intent-filter>
         <action android:name="com.google.firebase.MESSAGING_EVENT"/>
       </intent-filter>
      </service>

      <service android:name="com.evollu.react.fcm.InstanceIdService" android:exported="false">
       <intent-filter>
         <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
       </intent-filter>
      </service>

      <activity
        android:name=".MainActivity"
        android:label="${appName}"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
        android:screenOrientation="portrait"
        android:windowSoftInputMode="adjustPan"
        android:launchMode="singleTop">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
     <action android:name="android.intent.action.DOWNLOAD_COMPLETE"/>
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="foo"/>
        </intent-filter>
      </activity>
      <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
      <receiver
          android:name="com.adjust.sdk.AdjustReferrerReceiver"
          android:exported="true">
          <intent-filter>
              <action android:name="com.android.vending.INSTALL_REFERRER" />
          </intent-filter>
        </receiver>
    </application>

</manifest>

<!-- N/A -->

Environment


Think react-native-firebase is great? Please consider supporting the project with any of the below:

noahtallen commented 5 years ago

This seems similar to these issues which affected iOS. The solution was to update the native sdk versions.

levani commented 5 years ago

I have this issue on android after updating to rnfirebase 5.2.0. All native sdks are up to date. Any other solution?

levani commented 5 years ago

This sounds stupid I know but I got this error because I forgot to run npm install after setting rnfirebase version to 5.2.0 in package.json and then updating native dependencies.

t0m0120 commented 5 years ago

I also encountered the same error I tried building a comment code and built it

https://github.com/invertase/react-native-firebase/issues/1155#issuecomment-395944013

lalmachado commented 5 years ago

@taichi-jp try to put this: com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true on your android/app/build.gradle, i had the same problem and it worked for me.

taichi-jp commented 5 years ago

@t0m0120 @lalmachado I already tried it. After doint that, It succeeds Gradle sync, but crashes when launching the app. I guess that configuration is not a fundamental solution.

stale[bot] commented 5 years ago

Hello 👋, this issue has been automatically marked as stale because it has not had activity for quite some time. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 5 years ago

Closing this issue after a prolonged period of inactivity. If this is still present in the latest release, please feel free to create a new issue with up-to-date information.

GuleriaAshish commented 4 years ago

I am stuck into this issue. Can anyone solve it? I have tried adding both "com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true" and "googleServices { disableVersionCheck = true }" , but nothing works for me.