Hi - I'm running into problems integrating both appcenter-push and react-native-firebase to my project - it seems that there is a version mismatch. You can find my app/build.gradle here:
apply plugin: "com.android.application"
apply from: '../../node_modules/react-native-unimodules/gradle.groovy'
import com.android.build.OutputFile
/**
* The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
* and bundleReleaseJsAndAssets).
* These basically call `react-native bundle` with the correct arguments during the Android build
* cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
* bundle directly from the development server. Below you can see all the possible configurations
* and their defaults. If you decide to add a configuration block, make sure to add it before the
* `apply from: "../../node_modules/react-native/react.gradle"` line.
*
* project.ext.react = [
* // the name of the generated asset file containing your JS bundle
* bundleAssetName: "index.android.bundle",
*
* // the entry file for bundle generation
* entryFile: "index.android.js",
*
* // whether to bundle JS and assets in debug mode
* bundleInDebug: false,
*
* // whether to bundle JS and assets in release mode
* bundleInRelease: true,
*
* // whether to bundle JS and assets in another build variant (if configured).
* // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
* // The configuration property can be in the following formats
* // 'bundleIn${productFlavor}${buildType}'
* // 'bundleIn${buildType}'
* // bundleInFreeDebug: true,
* // bundleInPaidRelease: true,
* // bundleInBeta: true,
*
* // whether to disable dev mode in custom build variants (by default only disabled in release)
* // for example: to disable dev mode in the staging build type (if configured)
* devDisabledInStaging: true,
* // The configuration property can be in the following formats
* // 'devDisabledIn${productFlavor}${buildType}'
* // 'devDisabledIn${buildType}'
*
* // the root of your project, i.e. where "package.json" lives
* root: "../../",
*
* // where to put the JS bundle asset in debug mode
* jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
*
* // where to put the JS bundle asset in release mode
* jsBundleDirRelease: "$buildDir/intermediates/assets/release",
*
* // where to put drawable resources / React Native assets, e.g. the ones you use via
* // require('./image.png')), in debug mode
* resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
*
* // where to put drawable resources / React Native assets, e.g. the ones you use via
* // require('./image.png')), in release mode
* resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
*
* // by default the gradle tasks are skipped if none of the JS files or assets change; this means
* // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
* // date; if you have any other folders that you want to ignore for performance reasons (gradle
* // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
* // for example, you might want to remove it from here.
* inputExcludes: ["android/**", "ios/**"],
*
* // override which node gets called and with what additional arguments
* nodeExecutableAndArgs: ["node"],
*
* // supply additional arguments to the packager
* extraPackagerArgs: []
* ]
*/
project.ext.react = [
entryFile: "index.js"
]
apply from: "../../node_modules/react-native/react.gradle"
project.ext.vectoricons = [
iconFontNames: [ "MaterialIcons.ttf", "FontAwesome.ttf" ]
]
apply from: "../../node_modules/react-native-vector-icons/fonts.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.
*/
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion rootProject.ext.compileSdkVersion
defaultConfig {
applicationId "com.locelle.app"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 13
versionName "1.3"
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86", "arm64-v8a"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
// 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]
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
}
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildToolsVersion '28.0.3'
}
dependencies {
implementation project(':react-native-firebase')
implementation project(':@react-native-community_async-storage')
implementation project(':react-native-vector-icons')
// Firebase
implementation "com.google.android.gms:play-services-base:16.1.0"
implementation "com.google.firebase:firebase-core:16.0.9"
implementation "com.google.firebase:firebase-invites:17.0.0"
// AppCenter
implementation project(':appcenter-push')
implementation project(':appcenter-crashes')
implementation project(':appcenter-analytics')
implementation project(':appcenter')
// Unimodules
addUnimodulesDependencies()
api project(':expo-constants')
implementation project(':unimodules-react-native-adapter')
// GIF Support
implementation "com.facebook.fresco:animated-gif:1.10.0"
// Other
implementation project(':react-native-splash-screen')
implementation project(':react-native-svg')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+" // From node_modules
}
// 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'
// com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true
and the output from react-native run-android here:
info JS server already running.
info Building and installing the app on the device (cd android && ./gradlew app:installDebug)...
> Configure project :app
Installing unimodules:
[email protected] from /Users/maximellison/Documents/workspace/Locelle/node_modules/@unimodules/core
[email protected] from /Users/maximellison/Documents/workspace/Locelle/node_modules/@unimodules/react-native-adapter
[email protected] from /Users/maximellison/Documents/workspace/Locelle/node_modules/expo-constants
[email protected] from /Users/maximellison/Documents/workspace/Locelle/node_modules/expo-file-system
[email protected] from /Users/maximellison/Documents/workspace/Locelle/node_modules/expo-font
[email protected] from /Users/maximellison/Documents/workspace/Locelle/node_modules/expo-image-picker
[email protected] from /Users/maximellison/Documents/workspace/Locelle/node_modules/expo-location
[email protected] from /Users/maximellison/Documents/workspace/Locelle/node_modules/expo-permissions
[email protected] from /Users/maximellison/Documents/workspace/Locelle/node_modules/expo-web-browser
[email protected] from /Users/maximellison/Documents/workspace/Locelle/node_modules/unimodules-barcode-scanner-interface
[email protected] from /Users/maximellison/Documents/workspace/Locelle/node_modules/unimodules-camera-interface
[email protected] from /Users/maximellison/Documents/workspace/Locelle/node_modules/unimodules-constants-interface
[email protected] from /Users/maximellison/Documents/workspace/Locelle/node_modules/unimodules-face-detector-interface
[email protected] from /Users/maximellison/Documents/workspace/Locelle/node_modules/unimodules-file-system-interface
[email protected] from /Users/maximellison/Documents/workspace/Locelle/node_modules/unimodules-font-interface
[email protected] from /Users/maximellison/Documents/workspace/Locelle/node_modules/unimodules-image-loader-interface
[email protected] from /Users/maximellison/Documents/workspace/Locelle/node_modules/unimodules-permissions-interface
[email protected] from /Users/maximellison/Documents/workspace/Locelle/node_modules/unimodules-sensors-interface
[email protected] from /Users/maximellison/Documents/workspace/Locelle/node_modules/unimodules-task-manager-interface
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
> Configure project :react-native-firebase
react-native-firebase: using React Native prebuilt binary from /Users/maximellison/Documents/workspace/Locelle/node_modules/react-native/android
> Task :app:preDebugBuild FAILED
Dependency resolved to an incompatible version: Dependency(fromArtifactVersion=ArtifactVersion(groupId=com.google.firebase, artifactId=firebase-messaging, version=17.3.4), toArtifact=Artifact(groupId=com.google.firebase, artifactId=firebase-iid), toArtifactVersionString=[17.0.4])
FAILURE: Build failed with an exception.
* What went wrong:
Failed to capture fingerprint of input files for task ':app:preDebugBuild' property 'compileManifests' during up-to-date check.
> In project 'app' a resolved Google Play services library dependency depends on another at an exact version (e.g. "[17.0.
4]", but isn't being resolved to that version. Behavior exhibited by the library will be unknown.
Dependency failing: com.google.firebase:firebase-messaging:17.3.4 -> com.google.firebase:firebase-iid@[17.0.4], but fire
base-iid version was 17.1.2.
The following dependencies are project dependencies that are direct or have transitive dependencies that lead to the art
ifact with the issue.
-- Project 'app' depends onto com.google.firebase:[email protected]
-- Project 'app' depends onto com.google.firebase:[email protected]
-- Project 'app' depends on project 'appcenter' which depends onto com.google.firebase:[email protected]
-- Project 'app' depends onto com.google.android.gms:[email protected]
-- Project 'app' depends onto com.google.firebase:[email protected]
-- Project 'app' depends onto com.google.android.gms:[email protected]
-- Project 'app' depends on project 'appcenter' which depends onto com.google.firebase:[email protected]
-- Project 'app' depends onto com.google.firebase:[email protected]
-- Project 'app' depends onto com.google.firebase:[email protected]
For extended debugging info execute Gradle from the command line with ./gradlew --info :app:assembleDebug to see the dep
endency paths to the artifact. This error message came from the google-services Gradle plugin, report issues at https://
github.com/google/play-services-plugins and disable by adding "googleServices { disableVersionCheck = false }" to your b
uild.gradle file.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 5s
66 actionable tasks: 1 executed, 65 up-to-date
error Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
error Command failed: ./gradlew app:installDebug. Run CLI with --verbose flag for more details.
Please list the steps used to reproduce your issue.
react-native infoinfo
React Native Environment Info:
System:
OS: macOS 10.14.5
CPU: (4) x64 Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz
Memory: 375.41 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 10.15.3 - ~/.nvm/versions/node/v10.15.3/bin/node
Yarn: 1.12.3 - /usr/local/bin/yarn
npm: 6.4.1 - ~/.nvm/versions/node/v10.15.3/bin/npm
Watchman: 4.7.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
Android SDK:
API Levels: 23, 25, 26, 27, 28
Build Tools: 23.0.1, 25.0.0, 25.0.2, 25.0.3, 26.0.1, 26.0.2, 26.0.3, 27.0.0, 27.0.3, 28.0.3
System Images: android-23 | Intel x86 Atom, android-23 | Google APIs Intel x86 Atom, android-26 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom, android-29 | Google APIs Intel x86 Atom
IDEs:
Android Studio: 3.1 AI-173.4819257
Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild
npmPackages:
react: 16.8.3 => 16.8.3
react-native: 0.59.3 => 0.59.3
npmGlobalPackages:
react-native-cli: 2.0.1
react-native-git-upgrade: 0.2.7
pod --versionNot a problem on iOS
Just tested myself and could not reproduce the issue with latest versions of both appcenter 2.0.0 and react-native-firebase 5.5.3.
I double checked that both SDKs pulls "com.google.firebase:firebase-messaging:18.0.0", the same version. Same for firebase-core 16.0.9 are pulled from both SDKs.
There is thus no conflict between appcenter-push and react-native-firebase with a vanilla integration.
I also noticed: com.google.firebase:firebase-messaging:17.3.4 in your logs: please update react-native-firebase to latest as it uses 18.0.0 in version 5.5.3.
Thanks for testing @guperrot. I have updated appcenter to 2.0.0 (already at 2.0.0) and react-native-firebase to 5.5.3 (was at 5.4.3), but still having the same issue. Do you think you could share your app/build.gradle for my reference?
I used https://github.com/microsoft/appcenter-sdk-react-native/blob/develop/TestApp/android/app/build.gradle where I installed react-native-firebase (not committed, just playing around) then tested with and without your
// Firebase
implementation "com.google.android.gms:play-services-base:16.1.0"
implementation "com.google.firebase:firebase-core:16.0.9"
implementation "com.google.firebase:firebase-invites:17.0.0"
section and that didn't change anything.
Oh we did the firebase update only in version 2.1.0 of AppCenter which is not released yet into React-Native, my bad, this test app uses a prerelease SDK.
The SDK release should be sometime next week.
@guperrot Again - thanks for your work on this. I was wondering why we were having different results! I'll watch for the 2.1.0 release - unfortunately this is a blocker for me.
If you cannot wait for the release there are workarounds:
There should be no critical problem at runtime if you ignore the conflict with:
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true
But we fixed a bug in 2.1.0 with Firebase 18 where the first run of the app would not send the push token.
If you can downgrade react-native-firebase to a version that would use Firebase 17.x in addition to the version disabling, that would be better.
There is another solution if you are willing to patch appcenter-push/android/build.gradle inside node_modules. You can replace the content of the file by:
apply plugin: 'com.android.library'
android {
compileSdkVersion rootProject.properties.get('compileSdkVersion', 26)
buildToolsVersion rootProject.properties.get('buildToolsVersion', '27.0.3')
defaultConfig {
minSdkVersion 16
targetSdkVersion rootProject.properties.get('targetSdkVersion', 26)
versionCode 41
versionName '2.0.0'
ndk {
abiFilters 'armeabi-v7a', 'x86'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
//noinspection GradleDynamicVersion
implementation ('com.facebook.react:react-native:+') {
exclude group: 'com.android.support'
}
api 'com.microsoft.appcenter:appcenter-push:2.1.0'
/*
* For projects that needs to execute :verifyReleaseResources yet have :lint also succeed,
* we need to depend on the same support lib version of the app.
* If we just need :lint to work, excluding the support libs from push/react native is enough,
* so if ext.supportLibVersion is undefined that should still work for older apps.
*/
def supportLibVersion = rootProject.properties.get('supportLibVersion');
if (supportLibVersion != null) {
api "com.android.support:appcompat-v7:${supportLibVersion}"
api "com.android.support:support-v4:${supportLibVersion}"
}
api 'com.microsoft.appcenter.reactnative:appcenter-react-native:2.0.0'
}
That should solve the issue but this file being inside node_modules, it's probably git ignored for you so you might need a script to overwrite the file.
Hey,
This bug should be fixed in the latest RN SDK release.
Just want to confirm that this did fix my issue. Thank you @dhei @guperrot !
@Maximell Thanks for confirming and you are very welcome! 馃憤
Most helpful comment
Hey,
This bug should be fixed in the latest RN SDK release.