Looks like the new gms breaks a lot of lib since "+" is now on the later version however it breaks the project.
Please if possible to support the ability to change the dependencies version for GCM: `https://github.com/facebook/react-native/issues/18479
If possible if someone can create a PR similar to what @christocracy to the react-native-maps that would be awesome.
Example: https://github.com/react-community/react-native-maps/pull/2047
Thanks!
Looks good @ivan133
It's not mine ;)
I just found someone already did it I've switched to this fork and it works.
+1
To fix this issue for now, I would recommend adding this grade plugin to the _very_ top of your app/build.gradle file:
plugins {
id 'com.onesignal.androidsdk.onesignal-gradle-plugin' version '0.8.1'
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
In the longer term, we will be fixing this issue in a cleaner way with an update to how the SDK handles dependencies. We will probably be releasing it in the next day or two.
@Nightsd01 I did add those options in my app/build.gradle but the problem still persist.
Cool, I hope the changes can be merged asap. Really appreciate for the short turnaround. Thanks.
@Nightsd01 yesterday my app was running normally, today is giving this error :(
even adding the plugin the error continues
@jxnata post your:
build.gradleapp/build.gradle@christocracy
build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
}
}
allprojects {
repositories {
mavenLocal()
jcenter()
maven {
url "$rootDir/../node_modules/react-native/android"
}
}
}
app/build.gradle:
plugins {
id 'com.onesignal.androidsdk.onesignal-gradle-plugin' version '0.8.1'
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
apply plugin: "com.android.application"
import com.android.build.OutputFile
project.ext.react = [
entryFile: "index.js"
]
apply from: "../../node_modules/react-native/react.gradle"
def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "**************"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
manifestPlaceholders = [onesignal_app_id: "***********", onesignal_google_project_number: "******"]
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false
include "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
applicationVariants.all { variant ->
variant.outputs.each { output ->
def versionCodes = ["armeabi-v7a":1, "x86":2]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) {
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
dependencies {
compile project(':react-native-onesignal')
compile project(':react-native-vector-icons')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:27.1.0"
compile "com.facebook.react:react-native:+"
}
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
You鈥檙e not implementing the gradle config params in your gradle files, producing erratic behaviour with multiple versions of google dependencies colliding.
@christocracy I am having the same issue as @jxnata . Here are my files:
build.gradle
`
def googlePlayServicesVersion = '15.0.1'
buildscript {
repositories {
jcenter()
mavenCentral()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.google.gms:google-services:3.0.0'
}
}allprojects {
repositories {
mavenLocal()
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
configurations.all {
resolutionStrategy {
force 'com.facebook.android:facebook-android-sdk:4.22.1'// react-native-admob force "com.google.android.gms:play-services-ads:$googlePlayServicesVersion" // force "com.google.android.gms:play-services-base:$googlePlayServicesVersion" // force "com.google.android.gms:play-services-maps:$googlePlayServicesVersion" // react-native-onesignal force "com.google.android.gms:play-services-gcm:$googlePlayServicesVersion" force "com.google.android.gms:play-services-analytics:$googlePlayServicesVersion" force "com.google.android.gms:play-services-location:$googlePlayServicesVersion" // react-native-google-sign-in force "com.google.android.gms:play-services-auth:$googlePlayServicesVersion" } }}
`
app/build.gradle
`plugins {
id 'com.onesignal.androidsdk.onesignal-gradle-plugin' version '0.8.1'
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
apply plugin: "com.android.application"
import com.android.build.OutputFile
/**
react-native bundle with the correct arguments during the Android buildapply from: "../../node_modules/react-native/react.gradle" line.project.ext.react = [
entryFile: "index.js"
]
apply from: "../../node_modules/react-native/react.gradle"
/**
/**
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.beonews"
minSdkVersion 16
targetSdkVersion 26
versionCode 22
versionName "2.8.4"
ndk {
abiFilters "armeabi-v7a", "x86"
}
// Enabling multidex support.
multiDexEnabled true
manifestPlaceholders = [onesignal_app_id: "****************************",
onesignal_google_project_number: "REMOTE"]
}
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"
}
}
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
}
}
}
}
dependencies {
compile project(':react-native-fast-image')
compile project(':react-native-admob')
compile project(':react-native-onesignal')
compile project(':react-native-fbsdk')
compile project(':react-native-blur')
compile project(':react-native-linear-gradient')
compile project(':react-native-vector-icons')
compile 'com.facebook.android:facebook-android-sdk:[4.22.1)'
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.1.1"
compile 'com.google.android.gms:play-services-ads:11.8.0'
compile "com.facebook.react:react-native:+" // From node_modules
}
//apply plugin: 'com.google.gms.google-services'
// 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'
}
`
@christocracy Sorry, but how do I do this? It's my first android app rsrs... Thanks!
To your build.gradle, add the following block at the bottom:
ext {
compileSdkVersion = 26
targetSdkVersion = 26
buildToolsVersion = "26.0.2"
supportLibVersion = "26.1.0"
googlePlayServicesVersion = "11.8.0"
}
Many 3rd party modules are aware of these variables and will align their dependencies to them. It's up to you to decide what specific versions to apply.
In your android/build.gradle now, use these variables:
android {
+ compileSdkVersion rootProject.compileSdkVersion
+ buildToolsVersion rootProject.buildToolsVersion
defaultConfig {
+ targetSdkVersion rootProject.targetSdkVersion
.
.
.
}
}
dependencies {
.
.
+ compile "com.android.support:appcompat-v7:$rootProject.supportLibVersion" // <-- note double-quotes for variable interpolation
////
// If you're importing play-services dependencies in your project, use the
// googlePlayServicesVersion
//
+ compile "com.google.android.gms:play-services-ads:$rootProject.googlePlayServicesVersion"
}
@christocracy
Thank u for the explanation! Unfortunately it still gives the same error...
I will search more about
@ayush221b @christocracy I was finally able to solve it! The error was in the gradle wrapper version. I was using version 2.14, updated and worked perfectly:
/android/gradle/wrapper/gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
You'll want to get in the habit of using these Gradle Configuration Properties. You can visit the android/build.gradle of any module to see if they're supported.
eg: here's onesignal's build.gradle: note how it fetches values from rootProject.
Many other modules are aware of these variables. Eg: here's react-native-maps and react-native-device-info
Most helpful comment
You'll want to get in the habit of using these Gradle Configuration Properties. You can visit the
android/build.gradleof any module to see if they're supported.eg: here's
onesignal'sbuild.gradle: note how it fetches values fromrootProject.Many other modules are aware of these variables. Eg: here's
react-native-mapsandreact-native-device-info