skip to Main Content

I am trying to build my app on cordova to android. Cordova, Gradle and cordova-android was out of date, so i update them. The versions now are:

  • Node 16.13.2
  • npm 8.1.2
  • cordova 11.0.0
  • cordova-android 11.0.0
  • Gradle 7.6
  • JDK 11.0.16
  • AndroidAPI 32
  • Android SDK build-tools 32.0.0

Command:
cordova build --debug android --buildConfig

Error on console:

cordova-plugin-androidx-adapter: Processed 61 source files in 2342ms
[cordova-plugin-push::before-compile] skipping before_compile hookscript.
Checking Java JDK and Android SDK versions
ANDROID_HOME=C:UsersbryanAppDataLocalAndroidSdk (recommended setting)
ANDROID_SDK_ROOT=C:UsersbryanAppDataLocalAndroidSdk (DEPRECATED)
Using Android SDK: C:UsersbryanAppDataLocalAndroidSdk
Reading build config file: C:UsersbryanDocumentsTCHEbitBucketbackendbuild.json
Reading the keystore from: C:UsersbryanDocumentsTCHEbitBucketbackendtchedelivery.keystore
Subproject Path: CordovaLib
Subproject Path: app

> Configure project :app
Adding classpath: com.google.gms:google-services:4.3.8

> Task :app:compileDebugKotlin
w: Runtime JAR files in the classpath should have the same version. These files were found in the classpath:
    C:/Users/bryan/.gradle/caches/transforms-3/37c16254af6de93c45d2587b8dfcd992/transformed/jetified-kotlin-stdlib-jdk7-1.5.20.jar (version 1.5)
    C:/Users/bryan/.gradle/caches/transforms-3/efb587c616850f9dc0cda8853a96db77/transformed/jetified-kotlin-stdlib-1.6.21.jar (version 1.6)
    C:/Users/bryan/.gradle/caches/transforms-3/b6f68fc904e7a7217e6038f3031dcf3a/transformed/jetified-kotlin-stdlib-common-1.6.21.jar (version 1.6)
w: Some runtime JAR files in the classpath have an incompatible version. Consider removing them from the classpath
e: C:UsersbryanDocumentsTCHEbitBucketbackendplatformsandroidappsrcmainjavacomadobephonegappushPushInstanceIDListenerService.kt: (5, 32): Unresolved reference: FireBaseInstanceId
e: C:UsersbryanDocumentsTCHEbitBucketbackendplatformsandroidappsrcmainjavacomadobephonegappushPushInstanceIDListenerService.kt: (25, 5): Unresolved reference: FireBaseInstanceId
e: C:UsersbryanDocumentsTCHEbitBucketbackendplatformsandroidappsrcmainjavacomadobephonegappushPushPlugin.kt: (19, 32): Unresolved reference: FireBaseInstanceId
e: C:UsersbryanDocumentsTCHEbitBucketbackendplatformsandroidappsrcmainjavacomadobephonegappushPushPlugin.kt: (465, 19): Unresolved reference: FireBaseInstanceId
e: C:UsersbryanDocumentsTCHEbitBucketbackendplatformsandroidappsrcmainjavacomadobephonegappushPushPlugin.kt: (472, 21): Unresolved reference: FireBaseInstanceId
e: C:UsersbryanDocumentsTCHEbitBucketbackendplatformsandroidappsrcmainjavacomadobephonegappushPushPlugin.kt: (615, 11): Unresolved reference: FireBaseInstanceId

> Task :app:compileDebugKotlin FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugKotlin'.
> Compilation error. See log for more details

* Try:
> Run with --stacktrace option to get the stack trace.

This only occurs when i add the "onesignal-cordova-plugin". the plugin version is 3.3.0 (latest).

I have tried to update all the build tools (cordova was 9, i update it to 11, same to cordova-android, gradle was 6.6.1, i updated it to 7.6,…)

I have tried clean gradle cache ("C:/Users/bryan/.gradle/caches/transforms-3/")

2

Answers


  1. Chosen as BEST ANSWER

    I was using two push notification plugins, cordova-plugin-push and onesignal-cordova-plugin. The problem happened when i tried to build to android. Onesignal did not have any reference to 'FireBaseInstanceId' on its code, so the problem was on cordova-plugin-push. What resolves to me: I updated the plugin https://www.npmjs.com/package/@havesource/cordova-plugin-push to 4.0.0-dev.0 version instead of 3.0.1 (current default).


  2. First and foremost, don’t do multiple upgrades at once. Especially cordova-android. Go version by version and read the relevant update docs. They are major versions and thus have breaking changes. If you have to solve several errors at once you are making it even harder on yourself (cordova-android-10 is also fine for now in my opinion). target-sdk upgrades also include breaking changes. here are the update docs for cordova-android 10, they exist for all versions: https://cordova.apache.org/announcements/2021/07/20/cordova-android-10.0.0.html

    As to your specific error, which version of phone-plugin-push are you using (that seems to be throwing your error)? is it this one: https://www.npmjs.com/package/phonegap-plugin-push? Because it has a big deprecation warning, we switched to this one: https://www.npmjs.com/package/@havesource/cordova-plugin-push (not sure if this was the reason or some other issue). But you’re still going to need to patch that to add FLAG_MUTABLE where required. (you can do this with patch-package)
    This issue in the plugin repo might also shed some light on this error: https://github.com/phonegap/phonegap-plugin-push/issues/2768
    the root cause seems to be that the implementation of that instanceID has changed.

    Let me know if this solves your issues or if there are any remaining errors. I have done those updates myself and I know that they can be a pain and may require some more hooks and patches.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search