React-native-onesignal: React native onesignal could not be build

Created on 28 May 2018  ·  21Comments  ·  Source: OneSignal/react-native-onesignal

Hi,
I try to build my project but i get an error

> Could not resolve all dependencies for configuration ':app:_debugApk'.
   > A problem occurred configuring project ':react-native-onesignal'.
      > Could not find play-services-base-license.jar (com.google.android.gms:play-services-base-license:12.0.1).
        Searched in the following locations:
            https://jcenter.bintray.com/com/google/android/gms/play-services-base-license/12.0.1/play-services-base-license-12.0.1.jar

Till yesterday everything was fine, and now suddenly i get this error. Any idea ?

Most helpful comment

Add maven { url 'https://maven.google.com' } as first entry in allprojects/repositories in top level in android\build.gradle

All 21 comments

I think it's a problem with jcenter.
We find a similar problem here too:

https://github.com/rebeccahughes/react-native-device-info/issues/413

I tried something here but now i get
A problem occurred configuring project ':app'.

> Could not resolve all dependencies for configuration ':app:_debugApk'.
   > A problem occurred configuring project ':react-native-onesignal'.
      > Could not find runtime.jar (android.arch.lifecycle:runtime:1.0.0).
        Searched in the following locations:
            https://jcenter.bintray.com/android/arch/lifecycle/runtime/1.0.0/runtime-1.0.0.jar

yes, the same thing that happens to me.
I linked the issue of another library

yes, i have the same problem with building project in android.
@avishayil,
@Nightsd01
@jkasten2
```

Could not resolve all dependencies for configuration ':app:_debugApk'.
A problem occurred configuring project ':react-native-onesignal'.
Could not find firebase-messaging.jar (com.google.firebase:firebase-messaging:12.0.0).

Add maven { url 'https://maven.google.com' } as first entry in allprojects/repositories in top level in android\build.gradle

@Arshiya7
this is my android/build.gradle, where should i insert the maven url ?

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'

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

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

buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'

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

}

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

ok, the app build now works and starts but does not work onesignal.
Returns to me this error:

image

on adding this mavin url - app crush before loading
happend to you too ?

05-29 11:43:43.057 3938-3938/? E/AndroidRuntime: FATAL EXCEPTION: main
                                                 Process: com.guesty, PID: 3938
                                                 java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/internal/zzbq;
                                                     at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source:2)
                                                     at android.app.ActivityThread.installProvider(ActivityThread.java:6239)
                                                     at android.app.ActivityThread.installContentProviders(ActivityThread.java:5805)
                                                     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5722)
                                                     at android.app.ActivityThread.-wrap1(Unknown Source:0)
                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656)
                                                     at android.os.Handler.dispatchMessage(Handler.java:106)
                                                     at android.os.Looper.loop(Looper.java:164)
                                                     at android.app.ActivityThread.main(ActivityThread.java:6494)
                                                     at java.lang.reflect.Method.invoke(Native Method)
                                                     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
                                                  Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.internal.zzbq" on path: DexPathList[[zip file "/data/app/com.guesty-He-aS3-vlXVyJe9QisrxRg==/base.apk"],nativeLibraryDirectories=[/data/app/com.guesty-He-aS3-vlXVyJe9QisrxRg==/lib/x86, /system/fake-libs, /data/app/com.guesty-He-aS3-vlXVyJe9QisrxRg==/base.apk!/lib/x86, /system/lib, /vendor/lib]]
                                                     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
                                                     at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
                                                     at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
                                                     at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source:2) 
                                                     at android.app.ActivityThread.installProvider(ActivityThread.java:6239) 
                                                     at android.app.ActivityThread.installContentProviders(ActivityThread.java:5805) 
                                                     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5722) 
                                                     at android.app.ActivityThread.-wrap1(Unknown Source:0) 
                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656) 
                                                     at android.os.Handler.dispatchMessage(Handler.java:106) 
                                                     at android.os.Looper.loop(Looper.java:164) 
                                                     at android.app.ActivityThread.main(ActivityThread.java:6494) 
                                                     at java.lang.reflect.Method.invoke(Native Method) 
                                                     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) 
                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) 

Try to add this in file android/gradle.properties

googlePlayServicesVersion=12.0.1

@Richi2293
tried googlePlayServicesVersion=12.0.1, compiled fine, but onesignal not active at all in that case

is that works for you?

what version of onesignal are you using?

@erez-guesty yes and now you can fix onesignal like this:
(i followed what lahed says, I did some tests and it seems to work)
(onesignal version 3.2.4, i think is the last)

https://github.com/geektimecoil/react-native-onesignal/issues/525#issuecomment-392224930

@Richi2293
i have collision with react-native-device-info package 1.0.0 which is not finding its jar, happens when i follow Lahed instruction to change android version to 26+

I post my files:

android/gradle.properties

android.useDeprecatedNdk=true
googlePlayServicesVersion=12.0.1

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 26
buildToolsVersion "26.0.2"

defaultConfig {
    applicationId "it.wammo.wammo"
    minSdkVersion 16
    targetSdkVersion 22
    versionCode 1
    versionName "1.0"
    ndk {
        abiFilters "armeabi-v7a", "x86"
    }
}
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"
    }
}
// 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-onesignal')
compile project(':react-native-device-info')
compile project(':react-native-vector-icons')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:26.0.1"
compile "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'
}

android/build.gradle

buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'

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

}

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

@erez-guesty Please try adding the OneSignal Gradle Plugin to your project. This can be done by adding this snippet of code to the top of your app/build.gradle file:

buildscript {
    repositories {
        maven { url 'https://plugins.gradle.org/m2/'}
    }
    dependencies {
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.10.0, 0.99.99]'
    }
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

@Nightsd01
added the snippet to the top of my ~/android/app/build.gradle file
still not working

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugApk'.
   > A problem occurred configuring project ':react-native-onesignal'.
      > Could not find firebase-messaging.jar (com.google.firebase:firebase-messaging:12.0.0).
        Searched in the following locations:
            https://jcenter.bintray.com/com/google/firebase/firebase-messaging/12.0.0/firebase-messaging-12.0.0.jar

image

Any Updates ? I am getting

* What went wrong:
Execution failed for task ':react-native-onesignal:processReleaseResources'.
> Error: more than one library with package name 'com.google.android.gms.license'

I am also using react-native-google-signin

compile project(':react-native-onesignal')
    compile (project(":react-native-google-signin")){
          exclude group: "com.google.android.gms" // very important
      }
    compile 'com.google.android.gms:play-services-auth:11.+' // should be at least 9.0.0
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:+"  // From node_modules

@neel132 Please post your app/build.gradle

Assuming that you managed to fix your issue, so I'll be closing the ticket, if so please post whatever steps you took to resolve the problem!

If anyone still encounters this problem please let me know and I'll reopen & help investigate.

I just want to add this here: I had the same issue & then realised that I did not place the following code on the 1st line: (I had it in the middle of my build.gradle file)

buildscript {
    repositories {
        maven { url 'https://plugins.gradle.org/m2/' } // Gradle Plugin Portal
    }
    dependencies {
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.10.0, 0.99.99]'
    }
}


apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

Ensure that the above code is on the 1st line of your app/build.gradle

i am getting this error while i running my project in android

  • What went wrong:
    A problem occurred evaluating project ':app'.

    Project with path ':react-native-device-info' could not be found in project ':app'.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

Was this page helpful?
0 / 5 - 0 ratings