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

[Bug]: Freshly created Ionic Vue project cannot be run on Android #7847

Closed
1 of 3 tasks
Albermonte opened this issue Jan 28, 2025 · 14 comments
Closed
1 of 3 tasks

[Bug]: Freshly created Ionic Vue project cannot be run on Android #7847

Albermonte opened this issue Jan 28, 2025 · 14 comments

Comments

@Albermonte
Copy link

Capacitor Version

💊   Capacitor Doctor  💊 

Latest Dependencies:

  @capacitor/cli: 7.0.1
  @capacitor/core: 7.0.1
  @capacitor/android: 7.0.1
  @capacitor/ios: 7.0.1

Installed Dependencies:

  @capacitor/ios: not installed
  @capacitor/cli: 7.0.1
  @capacitor/core: 7.0.1
  @capacitor/android: 7.0.1

[success] Android looking great! 👌

Other API Details

npm --version
10.9.0



node --version
v22.11.0


macOS Sequoia 15.2

Platforms Affected

  • iOS
  • Android
  • Web

Current Behavior

Cannot run the android build, this error shows in console:

        [Incubating] Problems report is available at:
        file:///Users/albermonte/proyectos/ionic-demo/android/build/reports/problems/problems-report.html
        
        FAILURE: Build failed with an exception.
        
        * What went wrong:
        Execution failed for task ':capacitor-android:compileDebugJavaWithJavac'.
        > error: invalid source release: 21

Expected Behavior

It only runs on iOS but not on Android

Project Reproduction

https://github.com/Albermonte/capacitor-v7-error

Additional Information

No response

@jcesarmobile
Copy link
Member

Are you using Android Studio Ladybug?
It's required for Capacitor 7

@jcesarmobile jcesarmobile added the needs reply needs reply from the user label Jan 28, 2025
@ionitron-bot ionitron-bot bot removed the triage label Jan 28, 2025
@Albermonte
Copy link
Author

Android Studio Ladybug Feature Drop | 2024.2.2
Build #AI-242.23726.103.2422.12816248, built on December 18, 2024
Runtime version: 21.0.4+-12422083-b607.1 aarch64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Toolkit: sun.lwawt.macosx.LWCToolkit
macOS 15.3
GC: G1 Young Generation, G1 Concurrent GC, G1 Old Generation
Memory: 2048M
Cores: 12
Metal Rendering is ON
Registry:
  ide.experimental.ui=true
  i18n.locale=

@Ionitron Ionitron removed the needs reply needs reply from the user label Jan 28, 2025
@Albermonte
Copy link
Author

Albermonte commented Jan 28, 2025

Btw, in Capactior docs there's a typo mentioning "Capacitor 6" instead of 7

@jcesarmobile
Copy link
Member

Your sample app is working fine for me.
Are you running with Android Studio or with npx cap run android?

@jcesarmobile jcesarmobile added the needs reply needs reply from the user label Jan 29, 2025
@Albermonte
Copy link
Author

Just tried running with Android Studio and it worked after "Gradle Sync" and "Clean Project", but still not working when running using npx cap run android

@Ionitron Ionitron removed the needs reply needs reply from the user label Jan 29, 2025
@jcesarmobile
Copy link
Member

Capacitor 7 requires JDK 21, Android Studio Ladybug is distributed with JDK 21 included, so it works out of the box, but for npx cap run android you'll have to set your JAVA_HOME to use JDK 21 or newer (but not 24 as that's still not supported by gradle).

What I do is to configure JAVA_HOME to point to the JDK shipped with Android Studio with this value /Applications/Android Studio.app/Contents/jbr/Contents/Home

@jcesarmobile jcesarmobile closed this as not planned Won't fix, can't repro, duplicate, stale Jan 29, 2025
@Albermonte
Copy link
Author

Thank you @jcesarmobile, that did the trick. I would suggest to include that in the docs or in the Upgrade Guide for users like me that used Capacitor 6 or older

@jcesarmobile
Copy link
Member

It's mentioned already on the upgrade Android Studio step
https://capacitorjs.com/docs/updating/7-0#upgrade-android-studio

@Albermonte
Copy link
Author

I meant the JAVA_HOME thing, I think it's worth to mention it where npx cap run android command is mentioned

@HermanSher
Copy link

so do I need to install Java 21 in order to run my app I created React Project but facing same issue with this npx cap run android

but when I try with android studio it install the APK through ADB
file:///C:/Users/herma/Downloads/IonicReact/myApp/android/build/reports/problems/problems-report.html

    FAILURE: Build failed with an exception.

    * What went wrong:
    Execution failed for task ':capacitor-android:compileDebugJavaWithJavac'.
    > error: invalid source release: 21

    * Try:
    > Run with --stacktrace option to get the stack trace.
    > Run with --info or --debug option to get more log output.
    > Run with --scan to get full insights.
    > Get more help at https://help.gradle.org.

    70 actionable tasks: 70 executed
    BUILD FAILED in 2s

@touy
Copy link

touy commented Feb 1, 2025

it seems the current gradle is not support by JAVA 21

@HermanSher
Copy link

it seems the current gradle is not support by JAVA 21

I have install Java 21 and it working but I want to know what if I want to use java 17

@touy
Copy link

touy commented Feb 1, 2025

it seems the current gradle is not support by JAVA 21

I have install Java 21 and it working but I want to know what if I want to use java 17

I have install java 21 , and I can not build ionic capacitor 7 , so I have to downgrade to 6 and downgrade to version 17 , as the gradle 8.12 can work well with java 17

I have just complete this package and it is fine

https://www.npmjs.com/package/serialconnectioncapacitor

@HermanSher
Copy link

I had 17 but I removed it and then I install Java 21 also set JAVA_HOME and then simply created a react project and I just follow these Steps.

  • ionic start myApp tabs --type react
  • npx cap add android
  • ionic build
  • npx cap sync android
  • ionic cap run android -l --external
    it installed my app and then I can develop edit my project

If any one know a way to use Java 17 please provide the steps

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

5 participants