txcxjp opened a new issue, #1685:
URL: https://github.com/apache/cordova-android/issues/1685

   # 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.
   
   ```
   PS C:\dev\MyProject> cordova run --emulator
   Checking Java JDK and Android SDK versions
   ANDROID_HOME=C:\Users\skyis\AppData\Local\Android\Sdk (recommended setting)
   ANDROID_SDK_ROOT=C:\Users\skyis\AppData\Local\Android\Sdk (DEPRECATED)
   Using Android SDK: C:\Users\skyis\AppData\Local\Android\Sdk
   Subproject Path: CordovaLib
   Subproject Path: app
   
   Deprecated Gradle features were used in this build, making it incompatible 
with Gradle 8.0.
   
   You can use '--warning-mode all' to show the individual deprecation warnings 
and determine if they come from your own scripts or plugins.
   
   See 
https://docs.gradle.org/7.6/userguide/command_line_interface.html#sec:command_line_warnings
   
   BUILD SUCCESSFUL in 3s
   50 actionable tasks: 50 up-to-date
   Built the following apk(s):
           
C:\dev\MyProject\platforms\android\app\build\outputs\apk\debug\app-debug.apk
   Checking Java JDK and Android SDK versions
   ANDROID_HOME=C:\Users\skyis\AppData\Local\Android\Sdk (recommended setting)
   ANDROID_SDK_ROOT=C:\Users\skyis\AppData\Local\Android\Sdk (DEPRECATED)
   Using Android SDK: C:\Users\skyis\AppData\Local\Android\Sdk
   Command failed with exit code 1: avdmanager list avd
   �G���[: 
���C���E�N���Xcom.android.sdklib.tool.AvdManagerCli�̃��[�h����LinkageError���������܂���
           java.lang.UnsupportedClassVersionError: 
com/android/sdklib/tool/AvdManagerCli has been compiled by a more recent 
version of the Java Runtime (class file version 61.0), this version of the Java 
Runtime only recognizes class file versions up to 55.0
   ```
   
   ## Information
   <!-- Include all relevant information that might help understand and 
reproduce the problem -->
   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](https://github.com/apache/cordova-android/blob/rel/12.0.1/lib/emulator.js),
 it indeed calls ```avdmanager``` command.
   
   According to the 
[document](https://cordova.apache.org/docs/en/12.x/guide/platforms/android/index.html),
 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 setting ```CORDOCA_JAVA_HOME``` 
as JDK11 and ```JAVA_HOME``` as JDK21 because Command-line tools is not part of 
Cordova and it should be execute with the Java specified with ```JAVA_HOME```, 
but it didn't work.
   
   Reading 
[java.js](https://github.com/apache/cordova-android/blob/rel/12.0.1/lib/env/java.js),
 if the environment variable ```CORDOVA_JAVA_HOME``` is specified, it set 
```JAVA_HOME``` as ```CORDOVA_JAVA_HOME```'s value and the original value of 
```JAVA_HOME``` is discarded.
   That may be why ```avdmanager``` is  executed with old java version.
   
   
   ### Command or Code
   <!-- What command or code is needed to reproduce the problem? -->
   ```
   cordova create MyProject
   cd MyProject
   cordova platform add android
   cordova run --emulator
   ```
   
   
   ### Environment, Platform, Device
   <!-- In what environment, on what platform or on which device are you 
experiencing the issue? -->
   Windows10 (Japanese language)
   Powershell 5.1.19041.3693
   
   #### Environment Variables
   - PATH
       - C:\Users\myname\AppData\Local\Android\Sdk\emulator
       - C:\Users\myname\AppData\Local\Android\Sdk\cmdline-tools\latest\bin
       - C:\Users\myname\AppData\Local\Android\Sdk\platform-tools
       - C:\Users\myname\AppData\Local\Android\Sdk\build-tools
   - ANDROID_HOME
       - C:\Users\myname\AppData\Local\Android\Sdk
   - ANDROID_SDK_ROOT
       - C:\Users\myname\AppData\Local\Android\Sdk
   - GRADLE_HOME
       - C:\ProgramData\chocolatey\lib\gradle\tools\gradle-8.4
   - JAVA_HOME
       - C:\Program Files\OpenJDK\jdk-21.0.1
   - CORDOVA_JAVA_HOME
       - C:\Program Files\OpenJDK\jdk-11
   
   ### Version information
   <!--
   What are relevant versions you are using?
   For example:
   Cordova: Cordova CLI, Cordova Platforms, Cordova Plugins
   Other Frameworks: Ionic Framework and CLI version
   Operating System, Android Studio, Xcode etc.
   -->
       Windows10 22H2
       Android SDK Build-tools 33.02
       Android SDK Command-line Tools(latest)  11.0
       Android Emulator    32.1.15
       Android SDK Platform-Tools  34.0.5
       Android Studio  Giraffe 2022.3.1 Patch 4
       Cordova 12.0.0 ([email protected])
       cordova-android 12.0.1
       Gradle  8.4
   
   ## Checklist
   <!-- Please check the boxes by putting an x in the [ ] like so: [x] -->
   
   - [x] I searched for existing GitHub issues
   - [x] I updated all Cordova tooling to most recent version
   - [x] I included all the necessary information above
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to