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

Cordova 12.0.0 - JAVA Warning on project import to Android Studio (Electric Eel 2022.1.1) #624

Closed
FranGhe opened this issue Aug 3, 2023 · 1 comment

Comments

@FranGhe
Copy link

FranGhe commented Aug 3, 2023

I re post here an issues that first of all I post on cordova-android thinking that was a its issues:
apache/cordova-android#1635

I have updated Cordova from 11.0.0 to 12.0.0 and the android platform from Android 11 to Android 12

When I make the import project to Android Studio Electric Eel 2022.1.1 I have a warning like this:

Multiple Gradle daemons might be spawned because the Gradle JDK and JAVA_HOME locations are different.
Project 'xxx' is using the following JDK location when running Gradle: '/Applications/Android Studio.app/Contents/jbr/Contents/Home'
The system environment variable JAVA_HOME is: '/Library/Java/JavaVirtualMachines/jdk-14.0.2.jdk/Contents/Home'
If you dont need to use different paths (or if JAVA_HOME is undefined), you can avoid spawning multiple daemons by setting JAVA_HOME and the JDK location to the same path.

How can I fix it? I need to use my java 14.0.2 installed on PC

Yes, I can it change it after the import, but I'll be more relaxed if it's automatic... is this a trouble of Cordova CLI, cordova-android or Android Studio?

255403744-3d5a2d91-a603-42d5-b36d-1934feb351fd
@breautek
Copy link
Contributor

breautek commented Aug 4, 2023

As hinted by my comment on your other ticket: apache/cordova-android#1635 (comment)

The option is controlled via the .idea file, which is a configuration file specific to Android Studio (It being an IDEA IDE). If I'm interpreting the message correctly, you're getting the warning because Android Studio expects that your Gradle JDK should match the system JAVA_HOME variable.

is this a trouble of Cordova CLI, cordova-android or Android Studio?

Cordova doesn't actually use android studio really, it only uses the Android SDK. These are two different products. I eel like it probably would be best to keep Cordova decoupled from the IDE otherwise that might be another dependency that needs to be managed, and the IDE is something that changes nearly annually if not more frequent. It's a high risk of a breaking change from occurring without any heads up or ability to actually control the dependency.

How can I fix it? I need to use my java 14.0.2 installed on PC

Cordova-android@12 while still uses AGP version that expects JDK 11, a JDK version up to 17 should work. So the answer is you'll need to configure Android Studio to use your system JDK, if you absolutely require JDK 14 for other things. This can probably automated via a after_platform_add hook. I don't think the file will exist at all after platform add. It's likely created once you open up Android Studio, but you should be able to take a copy of your file and provide it manually so that when you do open up android studio, the configuration file is read and AS should be configured they want you want it.

Note that the configuration file does have some absolute paths stored, so if you work in a team with developers on different machines, you may need to also template out those settings so that you can provide the absolute path dynamically

Note for cordova-android@11 users, cordova-android@11 uses an AGP version that expects a JDK version no higher than 11. Therefore if you require a system JDK higher than 11, unfortunately you'll be stuck with the warning unless if you can update to cordova-android@12. .

I'm closing this because it isn't a bug with Cordova. If you have further questions on how to use hooks, then the best place for community support is via Apache Cordova Discussions.

@breautek breautek closed this as not planned Won't fix, can't repro, duplicate, stale Aug 4, 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

2 participants