Description:
By adding graddle plugin, compilation breaks complaining about missing libraries
Environment
react-native:0.59.3
react-native-onesignal:^3.2.14
yarn installSteps to Reproduce Issue:
app/build.graddle file as suggested on docs./gradlew build> Could not resolve all task dependencies for configuration ':app:releaseRuntimeClasspath'.
> Could not find androidx.appcompat:appcompat:26.0.0.
Required by:
project :app > project :react-native-splash-screen
project :app > project :react-native-device-info
> Could not find androidx.legacy:legacy-support-v4:26.0.0.
Required by:
project :app > project :react-native-firebase
project :app > project :react-native-device-info
> Could not find androidx.media:media:26.0.0.
Required by:
project :app > project :react-native-device-info
> Could not find androidx.appcompat:appcompat:26.0.0.
Required by:
project :app > com.facebook.react:react-native:0.59.3
project :app > project :react-native-image-crop-picker > com.github.yalantis:ucrop:2.2.2-native
> Could not find androidx.legacy:legacy-support-v4:26.0.0.
Required by:
project :app > project :react-native-onesignal > com.onesignal:OneSignal:3.10.8
Anything else:
If I remove the plugin, compilation works but app crashes when a message arrives. Stacktrace is
java.lang.IllegalAccessError: com.google.firebase.messaging.FirebaseMessagingService
dalvik.system.DexFile.defineClassNative DexFile.java
dalvik.system.DexFile.defineClass DexFile.java:226
dalvik.system.DexFile.loadClassBinaryName DexFile.java:219
dalvik.system.DexPathList.findClass DexPathList.java:338
dalvik.system.BaseDexClassLoader.findClass BaseDexClassLoader.java:54
java.lang.ClassLoader.loadClass ClassLoader.java:511
java.lang.ClassLoader.loadClass ClassLoader.java:469
android.app.ActivityThread.handleCreateService ActivityThread.java:3838
android.app.ActivityThread.access$2100 ActivityThread.java:229
android.app.ActivityThread$H.handleMessage ActivityThread.java:1909
android.os.Handler.dispatchMessage Handler.java:102
android.os.Looper.loop Looper.java:148
android.app.ActivityThread.main ActivityThread.java:7406
java.lang.reflect.Method.invoke Method.java
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run ZygoteInit.java:1230
com.android.internal.os.ZygoteInit.main ZygoteInit.java:1120
By checking into the plugin code, I manage to have the app working by adding
implementation "com.google.firebase:firebase-messaging:18.0.0"
Please make sure you have migrated to AndroidX
Yes, I have already migrated other dependencies using that guide. It seems to be linked to this compilation issue because it is trying to find a library that doesn't exist androidx.legacy:legacy-support-v4:26.0.0.. The real version is 1.0.0; it seems like a bug in the plugin when it tries to identify the correct version of libraries
@rgomezp @vmurillo I'm having the same issue with my build. I have migrated all other libs over and can successfully build my app. When adding one signal plugin as per the docs, I get androidx dependency issues.
RN 0.60.0
buildscript {
repositories {
maven { url 'https://plugins.gradle.org/m2/' } // Gradle Plugin Portal
}
dependencies {
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.1, 0.99.99]'
}
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
@aldrinc @vmurillo Can you share a React Native project reproducing the issue? I have not been able to reproduce androidx.appcompat versions getting set to 26.0.0 issue
having the same issue after adding react-native-onsignal on RN 0.60.4
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:preDebugBuild'.
> Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.
> Could not find androidx.appcompat:appcompat:27.1.1.
Required by:
project :app > com.facebook.react:react-native:0.60.4
> Could not find androidx.legacy:legacy-support-v4:27.1.1.
Required by:
project :app > project :tipsi-stripe
> Could not find androidx.appcompat:appcompat:27.1.1.
Required by:
project :app > project :tipsi-stripe
> Could not find androidx.legacy:legacy-support-v4:27.1.1.
Required by:
project :app > project :react-native-onesignal > com.onesignal:OneSignal:3.11.1
project :app > project :tipsi-stripe > com.google.android.gms:play-services-wallet:11.8.0 > com.google.android.gms:play-services-basement:11.8.0
> Could not find androidx.appcompat:appcompat:27.1.1.
Required by:
project :app > project :tipsi-stripe > com.stripe:stripe-android:8.1.0
project :app > project :tipsi-stripe > com.stripe:stripe-android:8.1.0 > com.google.android.material:material:1.0.0
* 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 15s
error Failed to install the app. Make sure you have the
The issue is mismatch version of androidx.appcompat:appcompat:27.1.1 as in the document here https://developer.android.com/jetpack/androidx/migrate is androidx.appcompat:appcompat:1.0.0
I just update the file /node_modules/react-native-onesignal/android/build.gradle
implementation 'com.android.support:cardview-v7:27.1.1'
to
implementation 'androidx.cardview:cardview:1.0.0'
And this solve the error.
@vmurillo @aldrinc @XeeshanAnsari I was able to reproduce the issue and have fixed it in version
0.12.3 of the OneSignal-Gradle-Plugin.
If you resync gradle or do a clean build this new versions should be used automatically. If you still have issues I recommend updating the line in your build.gradle to ensure this version is being used.
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.3, 0.99.99]'
@jkasten2 I'm getting this:
OneSignalPlugin: WARNING: OneSignalPlugin: Downgraded 'com.android.support:28.0.0' -> 28 to prevent compile errors! Recommend updating your project's compileSdkVersion!
Is it normal?
@amadeu01 This should create any issues since they are both 28, I think the gradle isn't comparing the values correctly to omit the warning.
Can you open a ticket about this specific warning with as much detail as possible in it's template?
https://github.com/OneSignal/OneSignal-Gradle-Plugin/issues
If you are seeing any other issues related to the wrong version being selected for react native reply here and I can reopen the ticket. If you seeing any other issues please create a new github ticket here. Thanks!
Most helpful comment
@vmurillo @aldrinc @XeeshanAnsari I was able to reproduce the issue and have fixed it in version
0.12.3 of the OneSignal-Gradle-Plugin.
If you resync gradle or do a clean build this new versions should be used automatically. If you still have issues I recommend updating the line in your
build.gradleto ensure this version is being used.