Wednesday, 29 September 2021

Ionic Capacitor Android Build on Big Sur

I am able to add android to my project with:

$ ionic capacitor add android

however I am not able to run due to a java issue. When executing:

$ ionic capacitor run android

I get the following error:

[capacitor] ✔ Copying web assets from www to android/app/src/main/assets/public in 318.72ms
[capacitor] ✔ Creating capacitor.config.json in android/app/src/main/assets in 669.04μp
[capacitor] ✔ copy android in 340.12ms
[capacitor] ✔ Updating Android plugins in 4.06ms
[capacitor] [info] Found 4 Capacitor plugins for android:
[capacitor]        @capacitor/app@1.0.3
[capacitor]        @capacitor/haptics@1.0.3
[capacitor]        @capacitor/keyboard@1.0.3
[capacitor]        @capacitor/status-bar@1.0.3
[capacitor] ✔ update android in 40.03ms
[capacitor] ✖ Running Gradle build - failed!
[capacitor] [error] 
[capacitor]         FAILURE: Build failed with an exception.
[capacitor]         
[capacitor]         * What went wrong:
[capacitor]         Supplied javaHome must be a valid directory. You supplied: /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
[capacitor]         
[capacitor]         * Try:
[capacitor]         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.
[capacitor]         
[capacitor]         * Get more help at https://help.gradle.org
[capacitor]         
[ERROR] An error occurred while running subprocess capacitor.
        
        capacitor run android --target emulator-5554 exited with exit code 1.
        
        Re-running this command with the --verbose flag may provide more information.

When I type

java --version
openjdk 11.0.12 2021-07-20
OpenJDK Runtime Environment Temurin-11.0.12+7 (build 11.0.12+7)
OpenJDK 64-Bit Server VM Temurin-11.0.12+7 (build 11.0.12+7, mixed mode)

I have also updated my ~/.zshrc file accordingly:

export JAVA_HOME=/Library/Java/JavaVirtualMachines/temurin-11.jdk/Contents/Home
export PATH=$JAVA_HOME/bin:$PATH

export ANDROID_SDK_ROOT=$HOME/Library/Android/sdk

export PATH=$PATH:$ANDROID_SDK_ROOT/tools/bin
export PATH=$PATH:$ANDROID_SDK_ROOT/platform-tools
export PATH=$PATH:$ANDROID_SDK_ROOT/emulator
export PATH=$PATH:$ANDROID_SDK_ROOT/build-tools


from Ionic Capacitor Android Build on Big Sur

No comments:

Post a Comment