Open txcxjp opened 5 months ago
Next major for API 34 support will bump the JDK requirement to 17.
Despite the docs stating it requires JDK 11, JDK 17 should work on cordova-android@12. So you should be able to set CORDOVA_JAVA_HOME
to a JDK 17 environment, while keeping your JDK 21 environment. Note that JDK 21 won't work because cordova-android@12 is using gradle 7.6.
Alternatively downgrading command line tools package to version 10.0
will probably also work.
It's good to know that the command line tools actually has a dependency on the java runtime, so this definitely should be reflected in the docs, rather than suggesting to install the latest version.
Thank you for your reply.
The problem was solved by using JDK17 you suggested. As I don't know the criteria that this ticket can be closed, I'll keep this open. I think someone can close this if no problem remained for this project.
I agree with improbe the document by writing about JDK version or command-line tools version to prevent new entrants from stumbling if it is premise that command-line tools uses the same JDK version to cordova uses.
Thank you anyway.
I moved this to the docs repo. I think we should just document using a specific version of command line tools instead of latest.
Downgrading command line tools package from latest
to version 10.0
worked for me.
Here is my .zshrc
file at the moment:
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/platform-tools/
# changed below from /latest/bin
export PATH=$PATH:$ANDROID_HOME/cmdline-tools/10.0/bin/
export PATH=$PATH:$ANDROID_HOME/build-tools
export PATH=$PATH:$ANDROID_HOME/emulator/
Also deleted my node_modules
, platforms
, plugins
and ran npm i
, cordova platform add android
I'm able to run cordova run --emulator
As @breautek stated, if we could update Installing SDK Command-line Tools (latest)
to say to download 10.0
instead of latest
it would really help out people setting up Cordova.
Huge thanks!
Bug Report
Problem
cordova run --emulator
command fails and the emulator don't be launched.What is expected to happen?
The emulator starts and launch the sample application.
What does actually happen?
The application was built successfully but the emulator don't be launched. Below is the log the command outputted.
Information
The error message says that the command
avdmanager list avd
cannot execute because Java version is too old.avdmanager
command is part of Command-line tools and actually it doesn't work with Java11 which specified by Cordova.Reading emulator.js, it indeed calls
avdmanager
command.According to the document, using Environment Variable
CORDOCA_JAVA_HOME
, we can use multiple Java versions differently for Cordova and other programs. I thought that I can solve this problem by settingCORDOCA_JAVA_HOME
as JDK11 andJAVA_HOME
as JDK21 because Command-line tools is not part of Cordova and it should be execute with the Java specified withJAVA_HOME
, but it didn't work.Reading java.js, if the environment variable
CORDOVA_JAVA_HOME
is specified, it setJAVA_HOME
asCORDOVA_JAVA_HOME
's value and the original value ofJAVA_HOME
is discarded. That may be whyavdmanager
is executed with old java version.Command or Code
Environment, Platform, Device
Windows10 (Japanese language) Powershell 5.1.19041.3693
Environment Variables
Version information
Checklist