You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "txcxjp (via GitHub)" <gi...@apache.org> on 2023/11/24 16:21:23 UTC

[I] ```cordova run --emulator ``` not working with Android SDK Command-line Tool 11.0 [cordova-android]

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 (cordova-lib@12.0.1)
       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: issues-unsubscribe@cordova.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Re: [I] ```cordova run --emulator ``` not working with Android SDK Command-line Tool 11.0 [cordova-android]

Posted by "breautek (via GitHub)" <gi...@apache.org>.
breautek commented on issue #1685:
URL: https://github.com/apache/cordova-android/issues/1685#issuecomment-1826350696

   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.


-- 
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: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Re: [I] ```cordova run --emulator ``` not working with Android SDK Command-line Tool 11.0 [cordova-android]

Posted by "txcxjp (via GitHub)" <gi...@apache.org>.
txcxjp commented on issue #1685:
URL: https://github.com/apache/cordova-android/issues/1685#issuecomment-1837427269

   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.


-- 
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: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org