Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to build app for Android SDK 31 or 32. #218

Closed
DiegoSestito opened this issue Feb 15, 2023 · 27 comments
Closed

Unable to build app for Android SDK 31 or 32. #218

DiegoSestito opened this issue Feb 15, 2023 · 27 comments

Comments

@DiegoSestito
Copy link

Bug Report

It is not possible to build the application for android platform sdk 31 and 32 after adding the plugin.

Platform and Version: Android Sdk 31 and 32

cordova info Printout

Task :app:compileDebugKotlin FAILED
w: Runtime JAR files in the classpath should have the same version. These files were found in the classpath:
C:///.gradle/caches/transforms-3/385d3cef332eae6d8c833ca4a22c5d7f/transformed/jetified-kotlin-stdlib-jdk8-1.3.72.jar (version 1.3)
C:///.gradle/caches/transforms-3/37c16254af6de93c45d2587b8dfcd992/transformed/jetified-kotlin-stdlib-jdk7-1.5.20.jar (version 1.5)
C:///.gradle/caches/transforms-3/efb587c616850f9dc0cda8853a96db77/transformed/jetified-kotlin-stdlib-1.6.21.jar (version 1.6)
C:///.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:***\platforms\android\app\src\main\java\com\adobe\phonegap\push\PushPlugin.kt: (466, 57): Unresolved reference: token
e: C:*
**\platforms\android\app\src\main\java\com\adobe\phonegap\push\PushPlugin.kt: (619, 57): Unresolved reference: deleteToken

@beard7
Copy link

beard7 commented Mar 3, 2023

Same (or very similar) issue for me. It's very bizarre -- I've been quite happily building my app every few minutes, then bang... build fails. I've not added or removed any plugins, just changed some app JS.

> Task :app:compileDebugKotlin FAILED
w: Runtime JAR files in the classpath should have the same version. These files were found in the classpath:
    C:/Users/m.beard/.gradle/caches/transforms-3/cc5cc74c45c7cc5e76733fe8278ba926/transformed/jetified-kotlin-stdlib-jdk7-1.5.20.jar (version 1.5)
    C:/Users/m.beard/.gradle/caches/transforms-3/adaf9cac4b199e0779758b8aae901bb4/transformed/jetified-kotlin-stdlib-1.7.10.jar (version 1.7)
    C:/Users/m.beard/.gradle/caches/transforms-3/eda4e3aecc1ddb0771d71f6ab843e15d/transformed/jetified-kotlin-stdlib-common-1.7.10.jar (version 1.7)
w: Some runtime JAR files in the classpath have an incompatible version. Consider removing them from the classpath
e: Incompatible classes were found in dependencies. Remove them from the classpath or use '-Xskip-metadata-version-check' to suppress errors
e: C:/Users/m.beard/.gradle/caches/modules-2/files-2.1/androidx.annotation/annotation/1.5.0/857678d6b4ca7b28571ef7935c668bdb57e15027/annotation-1.5.0.jar!/META-INF/annotation.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1.

I've not posted the entire error log as it goes on and on, but the key seems to be:

Class 'kotlin.somehting' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1.

Removing the plugin fixes the issue, but that's not really an option.

@rpinto78
Copy link

rpinto78 commented Mar 3, 2023

Same here.
Yesterday everything was working fine.

@DiegoSestito
Copy link
Author

I don't remember exactly what I did to fix this problem, because I had several problems trying to get my app to work for sdk 32. But I believe that reinstalling all my plugins in the most current version and installing jdk 11, one of these two things solved it. Maybe you should start by trying to install JDK 11.

@DiegoSestito
Copy link
Author

And of course, make sure you are running the most current version of cordova and cordova-android.

@beard7
Copy link

beard7 commented Mar 3, 2023

Thanks, but none of that explains how the app will build without problems, but then fail a few minutes later. I'm already on JDK11. Also, the latest cordova-android is 11.0.0, which is not a trivial update to 10.1.2.

@preziotte
Copy link

I think I was able to fix this by adding the following to my config:

<preference name="GradlePluginKotlinEnabled" value="true" />
<preference name="GradlePluginKotlinVersion" value="1.7.10" />

My build succeeds at least. No idea why this just started happening. Everything was fine a day or two ago.

@wloges
Copy link

wloges commented Mar 4, 2023

preziotte - You made my day, after I lost two other days for looking for a solution.
BTW it is f...g crazy when one day cordova stops compiling app without any warning.

@OpenSystemsConsulting
Copy link

@preziotte - worked for us too - thank you very much (our builds stopped working late last Friday after being fine all day)

Does anyone know and/or understand exactly what caused this to happen?

@beard7
Copy link

beard7 commented Mar 6, 2023

@preziotte thanks. I coud have sworn I'd already tried that, but it does indeed work. Maybe it was after I'd removed annd re-added the plugin and platform a few times.

@saggio89
Copy link

saggio89 commented Mar 6, 2023

I think I was able to fix this by adding the following to my config:

<preference name="GradlePluginKotlinEnabled" value="true" />
<preference name="GradlePluginKotlinVersion" value="1.7.10" />

My build succeeds at least. No idea why this just started happening. Everything was fine a day or two ago.

Ah I thought i was going crazy! My builds were working fine 2 weeks ago, changed nothing & wasn't working today :(.
Spent all day looking for a fix until I came across @preziotte's solution. Fixed it for me! Thank you!

@matscav
Copy link

matscav commented Mar 8, 2023

Thank you @preziotte!
This kind of things are pushing me to migrate everything to capacitor 😓

@preziotte
Copy link

@matscav what's capacitor?

@lichkessel
Copy link

lichkessel commented Mar 8, 2023

Me either had the same problem. Trying to fix it, I deleted ~/.gradle/caches, then deleted entire ~/.gradle. Nothing helped: my assembly chain creates the cordova project from scratch each build; I have the recent Java SDK.
Indeed, my build chain worked two weeks ago, and now it's broken without any changes from my side. Nevertheless, the solution of @preziotte (thank you, mate !) worked to me. I'm curious what happened...
The output of my build toolchain is the following (after clean launch) :

Task :app:compileDebugKotlin FAILED
w: Runtime JAR files in the classpath should have the same version. These files were found in the classpath:
    /Users/xxx/.gradle/caches/transforms-3/37c16254af6de93c45d2587b8dfcd992/transformed/jetified-kotlin-stdlib-jdk7-1.5.20.jar (version 1.5)
    /Users/xxx/.gradle/caches/transforms-3/16f0fa7a8f147bbbdd08181b1d0ed2ab/transformed/jetified-kotlin-stdlib-1.7.10.jar (version 1.7)
    /Users/xxx/.gradle/caches/transforms-3/727d189c560aae87eb38bbb136e543d5/transformed/jetified-kotlin-stdlib-common-1.7.10.jar (version 1.7)
w: Some runtime JAR files in the classpath have an incompatible version. Consider removing them from the classpath
e: Incompatible classes were found in dependencies. Remove them from the classpath or use '-Xskip-metadata-version-check' to suppress errors
e: /Users/xxx/.gradle/caches/modules-2/files-2.1/androidx.annotation/annotation/1.5.0/857678d6b4ca7b28571ef7935c668bdb57e15027/annotation-1.5.0.jar!/META-INF/annotation.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1.
e: /Users/xxx/.gradle/caches/transforms-3/16f0fa7a8f147bbbdd08181b1d0ed2ab/transformed/jetified-kotlin-stdlib-1.7.10.jar!/META-INF/kotlin-stdlib.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1.
e: /Users/xxx/.gradle/caches/transforms-3/727d189c560aae87eb38bbb136e543d5/transformed/jetified-kotlin-stdlib-common-1.7.10.jar!/META-INF/kotlin-stdlib-common.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1.
e: /Users/xxx/work/prescrire/guide/cordova/platforms/android/app/src/main/java/com/adobe/phonegap/push/BackgroundActionButtonHandler.kt: (14, 2): Class 'kotlin.Suppress' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1.
The class is loaded from /Users/xxx/.gradle/caches/transforms-3/16f0fa7a8f147bbbdd08181b1d0ed2ab/transformed/jetified-kotlin-stdlib-1.7.10.jar!/kotlin/Suppress.class
e: /Users/xxx/work/prescrire/guide/cordova/platforms/android/app/src/main/java/com/adobe/phonegap/push/BackgroundActionButtonHandler.kt: (31, 25): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1.

@meidlinga
Copy link

ref: #224

@matscav
Copy link

matscav commented Mar 9, 2023

@matscav what's capacitor?

https://capacitorjs.com/

shankari added a commit to shankari/e-mission-phone that referenced this issue Mar 14, 2023
Bump up the minSDK to API 23 (Marshmallow, Android 6)
    - I am not sure why this was API 22; we are certainly not testing on that version

Bump the targetSDK to API 32, android 12 (required for Google Play)
Switch the push and local notification plugins to ones that support the new trampoline functionality
https://developer.android.com/about/versions/12/behavior-changes-12#notification-trampolines

The push plugin is a "dev" version but seems to have all android fixes
It also bumps up the iOS version so that we can avoid the "non-public selectors" error
havesource/cordova-plugin-push#106
e-mission/e-mission-docs#838 (comment)

The push plugin had kotlin build errors that were fixed by adding the gradle preferences
havesource/cordova-plugin-push#218 (comment)

The local notification is a new fork maintained by a new author
which requires us to add the new `AndroidLaunchMode` preference.

The new plugins already have the compile -> implementation fix
So removing the hook added in 6de1f4c

Testing done:
- builds
- generated a local notification by turning off location permissions
- clicking on the notification opened the status screen
@veodko
Copy link

veodko commented Mar 15, 2023

I had the same error appear on me out of nowhere and I literally spent almost 2 days trying to figure it out. I even switched to MacOS for building thinking it's a Windows issue but it was exactly the same. Everything worked and suddenly stopped.

My app builds now after adding the preference, however on MacOS I encountered the problem somewhere else, but thankfully it doesn't cause the build to fail:

e: /Users/user/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.7.10/d2abf9e77736acc4450dc4a3f707fa2c10f5099d/kotlin-stdlib-1.7.10.jar!/META-INF/kotlin-stdlib.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.4.0.
e: /Users/user/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.7.10/1ef73fee66f45d52c67e2aca12fd945dbe0659bf/kotlin-stdlib-jdk7-1.7.10.jar!/META-INF/kotlin-stdlib-jdk7.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.4.0.
e: /Users/user/.gradle/caches/modules-2/files-2.1/androidx.annotation/annotation/1.5.0/857678d6b4ca7b28571ef7935c668bdb57e15027/annotation-1.5.0.jar!/META-INF/annotation.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.4.0.
e: /Users/user/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-android-extensions-runtime/1.7.10/6cf8c7aec5501d2892bc4392f0a109f68eb86da/kotlin-android-extensions-runtime-1.7.10.jar!/META-INF/kotlin-android-extensions-runtime.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.4.0.
e: /Users/user/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.7.10/bac80c520d0a9e3f3673bc2658c6ed02ef45a76a/kotlin-stdlib-common-1.7.10.jar!/META-INF/kotlin-stdlib-common.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.4.0.

Why did it fail in the first place if nothing has changed in the project? Even my cordova gradle config uses Kotlin 1.5.20 and somehow suddenly things stopped working?

@meidlinga
Copy link

meidlinga commented Mar 15, 2023

@veodko : it might be this problem #224

@veodko
Copy link

veodko commented Mar 16, 2023

@veodko : it might be this problem #224

I have already tried the modified version of the plugin, as well as adding the Kotlin version preference to cordova.
This error is thrown from task:lintVitalRelease and does not affect the build, I guess it's not a crucial task but I'm still a little concerned.
It complains about version 1.4.0 here so it's something that uses an even older version than the rest of Cordova.

This whole problem kinda looks like something just started ignoring older Kotlin versions and builds with 1.7.1 anyway. It's weird because during the cordova build I could see that kotlin compiler for 1.5.20 was being downloaded.
I thought that using the modified plugin & removing the preference would fix it (if the plugin was only one at fault) but it's still there.

@sjdrew
Copy link

sjdrew commented Mar 28, 2023

Just a bump for "capacitor". I maintain bunch of hybrid apps. About 50% on capacitor and 50% are still on cordova. The capacitor ones are a dream to maintain with zero issues, whereas every time I make a change on a cordova app, hours are wasted on issues just like this.

@veodko
Copy link

veodko commented Mar 29, 2023

Just a bump for "capacitor". I maintain bunch of hybrid apps. About 50% on capacitor and 50% are still on cordova. The capacitor ones are a dream to maintain with zero issues, whereas every time I make a change on a cordova app, hours are wasted on issues just like this.

It's true, cordova is a total mess with every single plugin not being maintained by anyone for 2-4 years and even if people try to maintain them by making PRs, no one accepts them so we end up with 10 forks of the same plugin. I'm only still using this garbage technology because of a large app written using cordova and meteorjs. There is no time to move this to anything newer, it would require a full rewrite to some other framework.

@vemulanishanth
Copy link

I think I was able to fix this by adding the following to my config:

<preference name="GradlePluginKotlinEnabled" value="true" />
<preference name="GradlePluginKotlinVersion" value="1.7.10" />

My build succeeds at least. No idea why this just started happening. Everything was fine a day or two ago.

I am upgrading an old project from cordova-android@10.x.x to cordova-android@11.x.x.

The build did not succeed in my project after this change. however, error regarding JAR Files disappeared.

image

@RiteshAryal
Copy link

@preziotte thanks for your suggestion as above.
I've applied your suggestion but it does not fix the build yet.

Given, I am using
Node - v18.15.0, NPM-v9.5.0, cordova-v11, cordova-android-v11, gulp-v3.9, android-sdk-build-tools-v32.0.0,

Please suggest:

> Task :app:compileReleaseKotlin
e: /path-to-my-app/platforms/android/app/src/main/java/com/adobe/phonegap/push/PushPlugin.kt: (466, 57): Unresolved reference: token
e: /path-to-my-app/platforms/android/app/src/main/java/com/adobe/phonegap/push/PushPlugin.kt: (619, 57): Unresolved reference: deleteToken

@clarklight
Copy link

Just a bump for "capacitor". I maintain bunch of hybrid apps. About 50% on capacitor and 50% are still on cordova. The capacitor ones are a dream to maintain with zero issues, whereas every time I make a change on a cordova app, hours are wasted on issues just like this.

It's true, cordova is a total mess with every single plugin not being maintained by anyone for 2-4 years and even if people try to maintain them by making PRs, no one accepts them so we end up with 10 forks of the same plugin. I'm only still using this garbage technology because of a large app written using cordova and meteorjs. There is no time to move this to anything newer, it would require a full rewrite to some other framework.

Thats why we should keep the community alive, and going, so we dont have to spend huge amount of time for rewrite.... Selfishly atleast keep the community going until our retirement lol

@Mike-Becatti
Copy link

Just a bump for "capacitor". I maintain bunch of hybrid apps. About 50% on capacitor and 50% are still on cordova. The capacitor ones are a dream to maintain with zero issues, whereas every time I make a change on a cordova app, hours are wasted on issues just like this.

Want to maintain one more? We are looking to outsource the maintenance of our Cordova app.

@igorsantos07
Copy link

igorsantos07 commented Sep 18, 2023

It's true, cordova is a total mess with every single plugin not being maintained by anyone for 2-4 years and even if people try to maintain them by making PRs, no one accepts them so we end up with 10 forks of the same plugin.

Thats why we should keep the community alive

@clarklight, that's exactly what the person before you said - people TRY to keep the community alive, but more and more companies are stopping with hybrid apps exactly because they're messy and the Cordova maintainers can't even keep a push plugin alive. This isn't even an official plugin, and unofficial plugins tend to do exactly this: get ghosted and fall out of maintenance. And then, people completely unrelated start showing up with issues and try to jerry-rig solutions (I even have my own fork of this, trying to fix #94 from more than 2 years ago), until someone more knowledgeable tries to steer the ship back to its course. Sadly, it's very rare for a new captain to show up, or the old one to wake up.
Bottom-line: the community is alive, but without captains to take control of the ships, we'll slowly drown. So we better jump ship before it's too late - and I feel it is, since there are years this essential plugin is taking dust around here...

@matthijsbierman
Copy link

@preziotte thanks for your suggestion as above. I've applied your suggestion but it does not fix the build yet.

Given, I am using Node - v18.15.0, NPM-v9.5.0, cordova-v11, cordova-android-v11, gulp-v3.9, android-sdk-build-tools-v32.0.0,

Please suggest:

> Task :app:compileReleaseKotlin
e: /path-to-my-app/platforms/android/app/src/main/java/com/adobe/phonegap/push/PushPlugin.kt: (466, 57): Unresolved reference: token
e: /path-to-my-app/platforms/android/app/src/main/java/com/adobe/phonegap/push/PushPlugin.kt: (619, 57): Unresolved reference: deleteToken

Make sure you do not only upgrade the push plugin to the latest version 4.0.0-dev.0 but either first uninstall the plugin with:

cordova plugin remove @havesource/cordova-plugin-push 

and then reinstall with:

cordova plugin add @havesource/cordova-plugin-push@dev

Or manually update the versions under cordova.plugins in package.json to the following:

"@havesource/cordova-plugin-push": {
    "ANDROIDX_CORE_VERSION": "1.6.+",
    "FCM_VERSION": "23.+",
    "IOS_FIREBASE_MESSAGING_VERSION": "~> 8.1.1"
}

Finally, you also need to make sure the POST_NOTIFICATIONS permission is present in config.xml:

<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>

Until #238 has been fixed you can use cordova-plugin-android-permissions to check for and request permissions.

@erisu
Copy link

erisu commented Oct 23, 2023

This issue should have been resolved with the latest released version 4.0.0. It has Kotlin version 1.7.21 set.

Please reinstall the plugin and try again.

@erisu erisu closed this as completed Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests