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

Errors when running skip checkup if java version > 17 #5

Open
Marsgames opened this issue Oct 27, 2023 Discussed in #4 · 28 comments
Open

Errors when running skip checkup if java version > 17 #5

Marsgames opened this issue Oct 27, 2023 Discussed in #4 · 28 comments

Comments

@Marsgames
Copy link

Error after first installation via brew and running skip checkup (with and without --double-check)

Maybe we can provide more info, to help resolving this issue?


Discussed in #4

Originally posted by oluarry October 27, 2023
This error came up when trying to build in xcode
I followed all the steps and made 2 different projects but same error in xcode
I ran skip doublecheck here
Screenshot 2023-10-26 at 11 18 07 PM

@Marsgames
Copy link
Author

Additional info:

Here's build error log when trying to build hello-skip project created via command skip init --open-xcode --appid=com.xyz.HelloSkip hello-skip HelloSkip

note: Building APK for: hello-skip
/Users/rd-headcrab/Library/Developer/Xcode/DerivedData/HelloSkip-dojafehjnlkuenaazualmlxxkzab/Build/Products/../../SourcePackages/artifacts/skip/skip/skip.artifactbundle/macos/skip
Error: Gradle run error: Optional(SkipDriveExternal.ProcessResult.ExitStatus.terminated(code: 1))
GRADLE> 
GRADLE> FAILURE: Build failed with an exception.
GRADLE> 
GRADLE> * What went wrong:
GRADLE> Could not determine the dependencies of task ':HelloSkip:packageDebug'.
GRADLE> > Could not create task ':HelloSkip:compileDebugJavaWithJavac'.
GRADLE>    > Failed to calculate the value of task ':HelloSkip:compileDebugJavaWithJavac' property 'javaCompiler'.
GRADLE>       > No matching toolchains found for requested specification: {languageVersion=17, vendor=any, implementation=vendor-specific} for MAC_OS on aarch64.
GRADLE>          > No locally installed toolchains match and toolchain download repositories have not been configured.
GRADLE> 
GRADLE> * Try:
GRADLE> > Learn more about toolchain auto-detection at https://docs.gradle.org/8.4/userguide/toolchains.html#sec:auto_detection.
GRADLE> > Learn more about toolchain repositories at https://docs.gradle.org/8.4/userguide/toolchains.html#sub:download_repositories.
GRADLE> > Run with --stacktrace option to get the stack trace.
GRADLE> > Run with --info or --debug option to get more log output.
GRADLE> > Run with --scan to get full insights.
GRADLE> > Get more help at https://help.gradle.org.
GRADLE> 
GRADLE> BUILD FAILED in 3s
note: Gradle command result: <ProcessResult: exit: terminated(code: 1), output:
 
>
error: Gradle run error: Optional(SkipDriveExternal.ProcessResult.ExitStatus.terminated(code: 1))

@KristofZelei
Copy link

KristofZelei commented Oct 27, 2023

I got the same error, please keep me updated if you find the solution.

@KristofZelei
Copy link

I found the solution, I had a newer version of JDK installed. Follow this documentation to uninstall your current version if it is above 17 or simply install version 17.

@Marsgames
Copy link
Author

I found the solution, I had a newer version of JDK installed. Follow this documentation to uninstall your current version if it is above 17 or simply install version 17.

Yep, working now. Thanks for your help!

cd /Library/Java/JavaVirtualMachines
sudo rm -rf JDK>17 # replace by your idk version
brew install openjdk@17

Issue can be closed (but info should be added to the installation readme?)

@Marsgames Marsgames changed the title Errors when running skip checkup Errors when running skip checkup if java version > 17 Oct 27, 2023
@DominatorVbN
Copy link

Even unistalling the newer JDK and installing openjdk@17 did not worked

  • Set the path in zshrc as well

It only worked when i added below line to the Build Android APK build phase script

export JAVA_HOME="/opt/homebrew/opt/openjdk@17/libexec/openjdk.jdk/Contents/Home"
export PATH=$JAVA_HOME/bin:$PATH

@marcprux
Copy link
Contributor

marcprux commented Oct 28, 2023

We released Skip 0.7.13 last night, which adds openjdk@17 as a dependency of the skip Homebrew package. Run skip upgrade from the command line and then ensure skip checkup passes to get the latest version. If it fails, please post the output of skip checkup --verbose.

Also, if you have a custom JAVA_HOME set (e.g. from your ~/.zshrc file), you may need to unset it for the process you run skip checkup and/or Xcode, otherwise Gradle may try to use an incompatible version.

For some background, Skip would like to be hands-off about which Java version it uses, since Android-focused developers may have limitations and needs for specific version. However, there's an open Gradle issue that prevents JDK 21 from working at all for Android builds; this is a problem for Homebrew's default recommended JDK temurin, which recently got bumped to version 21. So to work around that, we've added openjdk@17 as a prerequisite to Skip's Homebrew formula. In the future, we hope to enable developers to specify which JDK to use at the top-level (e.g., in Sources/App/Skip/skip.yml), but currently it is specified at the very lowest level of SkipUnit.

@tejuamirthi
Copy link

skip checkup passes with all checks but Build Android APK phase still fails.

I'm using Skip 0.7.13 but still facing the issue

This solution worked #5 (comment)

@shial4
Copy link

shial4 commented Oct 30, 2023

I had to add

JAVA_HOME=/usr/local/Cellar/openjdk@17/17.0.9/libexec/openjdk.jdk/Contents/Home
PATH=$JAVA_HOME/bin:$PATH

instead of /opt/homebrew/opt

@marcprux
Copy link
Contributor

marcprux commented Nov 1, 2023

Skip 0.7.16 adds some additional logic to use the /opt/homebrew/opt/openjdk@17 installation rather than the /opt/homebrew/opt/openjdk@21 (which is installed by gradle). This should fix situations where the openjdk@21 install is inadvertently used (and thus triggering the Gradle issue with Java 21).

Please let us know if this problem still affects you and we will re-open the issue.

@marcprux marcprux closed this as completed Nov 1, 2023
@rzil
Copy link

rzil commented Dec 4, 2023

I am using latest Skip version 0.7.31 but still facing the above issues.

@marcprux
Copy link
Contributor

marcprux commented Dec 4, 2023

Can you post the output of skip checkup --verbose?

@rzil
Copy link

rzil commented Dec 7, 2023

Can you post the output of skip checkup --verbose?

skipcheckup.txt

@marcprux
Copy link
Contributor

marcprux commented Dec 7, 2023

The problem is from this part of the log:

FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:compileReleaseKotlin'.
> Unknown Kotlin JVM target: 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.
BUILD FAILED in 15s
[✗] Assembling Android apk (15.17s)

Can you try forcing using openjdk 17 with the command:

brew link --overwrite openjdk@17

And then check the output of the java -version command:

% java -version
openjdk version "17.0.9" 2023-10-17
OpenJDK Runtime Environment Homebrew (build 17.0.9+0)
OpenJDK 64-Bit Server VM Homebrew (build 17.0.9+0, mixed mode, sharing)

@marcprux marcprux reopened this Dec 7, 2023
@rzil
Copy link

rzil commented Dec 7, 2023

I followed those steps but it didn't work. It seems skip is still choosing JDK version 21? Here is the output.

rubenz@MacBook-Pro ~ % brew link --overwrite openjdk@17
Linking /opt/homebrew/Cellar/openjdk@17/17.0.9... 63 symlinks created.

If you need to have this software first in your PATH instead consider running:
  echo 'export PATH="/opt/homebrew/opt/openjdk@17/bin:$PATH"' >> ~/.zshrc
rubenz@MacBook-Pro ~ % java -version
openjdk version "17.0.9" 2023-10-17
OpenJDK Runtime Environment Homebrew (build 17.0.9+0)
OpenJDK 64-Bit Server VM Homebrew (build 17.0.9+0, mixed mode, sharing)
rubenz@MacBook-Pro ~ % 
rubenz@MacBook-Pro ~ % skip checkup
[✓] Skip version 0.7.31 (= 0.7.31)
[✓] macOS version 14.1.2 (> 13.5.0)
[✓] Swift version 5.9 (= 5.9.0)
[✓] Xcode version 15.0.1 (> 15.0.0)
[✓] Homebrew version 4.1.22 (> 4.1.0)
[✓] Gradle version 8.5 (> 8.3.0)
[✓] Java version 21.0.1 (> 17.0.0)
[✓] Android Debug Bridge version 1.0.41 (> 1.0.40)
[✓] Android Studio version: 2023.1
[✓] Resolve dependencies (12.61s)
[✓] Build hello-skip (21.59s)
[✓] Test Swift (14.1s)
[✗] Test Kotlin (5.86s)
[✓] Archive iOS ipa (19.01s)
[✓] Assemble HelloSkip-release.ipa (0.01s)
[✓] Verify HelloSkip-release.ipa 23 KB
[✗] Assembling Android apk (14.42s)
[✗] Verify HelloSkip-release.apk: /var/folders/7p/g2ynv5wj1k9dfhcwms4r_z0r0000gn/T//E3FE27FF-E01C-4688-891D-6678D34D8093/hello-skip/.build/Android/app/outputs/apk/release/app-release-unsigned.apk: The file “app-release-unsigned.apk” couldn’t be opened because there is no such file.
[✓] Check Swift Package (0.38s)
[✗] Skip 0.7.31 checkup (96.37s)
Error: 4 errors

@Enzo-Dijoux
Copy link

I had the same problem @rzil :

  1. I installed skip using brew command, and by default the openjdk 21 is installed
  2. I installed openjdk 17 and tried 'brew link --overwrite openjdk@17'
  3. 'java -version' display the 17.0.9, but in skip checkup, the 21.0.1 is used

I fixed it, you can follow these instructions (not final fix):

  1. Check your current JAVA_HOME path -> 'echo $JAVA_HOME', in my case it was empty
  2. Update your JAVA_HOME path to the good version (17.0.9) -> 'export JAVA_HOME=$(/usr/libexec/java_home -v17.0.9)'
  3. Run 'skip checkup' again, the version of Java should be 17.0.9

@marcprux Inside the homebrew configuration file , the openjdk@21 is used, maybe the issue could come from here? This is my first time searching for an error with Homebrew, so I might be mistaken.

@rzil
Copy link

rzil commented Dec 8, 2023

Yes that did the trick. Need to set JAVA_HOME correctly. For some reason my java_home executable wasn't working but once I resolved that all good.

@roslog00
Copy link

roslog00 commented Dec 8, 2023

Hello, how do I correctly change the JAVA_HOME path? It shows my path, but the tests are not working.
Снимок экрана 2023-12-08 в 12 08 21 PM

@marcprux
Copy link
Contributor

Apologies for not getting back on this sooner. We're still working through some of the issues with Gradle 8.5 and OpenJDK. If you brew upgrade skip to 0.7.33, that version will try to automatically use opendk@17, and you can manually override if by setting export JAVA_HOME=/opt/homebrew/opt/openjdk@17/ from the terminal before running skip.

Please let us know if this helps.

@naticio
Copy link

naticio commented Feb 6, 2024

Apologies for not getting back on this sooner. We're still working through some of the issues with Gradle 8.5 and OpenJDK. If you brew upgrade skip to 0.7.33, that version will try to automatically use opendk@17, and you can manually override if by setting export JAVA_HOME=/opt/homebrew/opt/openjdk@17/ from the terminal before running skip.

Please let us know if this helps.

I followed these steps, still failed in the apk step
[✗] Assembling Android apk (13.94s)
[✗] Verify HelloSkip-release.apk: /var/folders/9_/xqn4bxx955z6npf3wh5n74nw0000gn/T//A8E02388-080F-455F-ABA4-FF69860E9AFC/hello-skip/.build/Android/app/outputs/apk/release/app-release-unsigned.apk: The file “app-release-unsigned.apk” couldn’t be opened because there is no such file.
[✓] Check Swift Package (0.41s)
[✗] Skip 0.8.2 checkup (101.02s)

I have 17.0.10 jdk installed. I also have react native/expo installed globally, may this be causing the error?

[✗] Assembling Android apk (12.99s)
[✗] Verify HelloSkip-release.apk: /var/folders/9_/xqn4bxx955z6npf3wh5n74nw0000gn/T//165E34ED-A7BF-4908-BD29-32B3C9334E33/hello-skip/.build/Android/app/outputs/apk/release/app-release-unsigned.apk: The file “app-release-unsigned.apk” couldn’t be opened because there is no such file.
executing command: /usr/bin/swift package dump-package --package-path /var/folders/9_/xqn4bxx955z6npf3wh5n74nw0000gn/T/165E34ED-A7BF-4908-BD29-32B3C9334E33/hello-skip
warning: 'hello-skip': /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend -frontend -c -primary-file /private/var/folders/9_/xqn4bxx955z6npf3wh5n74nw0000gn/T/A006AD53-0FE8-4E79-A700-D3B9229942E6/hello-skip/Package.swift -target arm64-apple-macosx13.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -stack-check -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -I /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -I /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/pm/ManifestAPI -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -vfsoverlay /var/folders/9_/xqn4bxx955z6npf3wh5n74nw0000gn/T/TemporaryDirectory.188kEh/vfs.yaml -swift-version 5 -package-description-version 5.9.0 -new-driver-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-driver -disable-implicit-concurrency-module-import -disable-implicit-string-processing-module-import -empty-abi-descriptor -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift -module-name main -disable-clang-spi -target-sdk-version 14.2 -target-sdk-name macosx14.2 -external-plugin-path '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/bin/swift-plugin-server' -external-plugin-path '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/local/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/bin/swift-plugin-server' -external-plugin-path '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server' -external-plugin-path '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/local/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server' -plugin-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/local/lib/swift/host/plugins -o /var/folders/9_/xqn4bxx955z6npf3wh5n74nw0000gn/T/TemporaryDirectory.iri2WW/Package-1.o
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang /var/folders/9_/xqn4bxx955z6npf3wh5n74nw0000gn/T/TemporaryDirectory.iri2WW/Package-1.o -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks --sysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk --target=arm64-apple-macosx13.0 -force_load /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/libswiftCompatibilityPacks.a -L /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx -L /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/lib/swift -L /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/pm/ManifestAPI -L /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -lPackageDescription -Xlinker -rpath -Xlinker /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/pm/ManifestAPI -o /var/folders/9_/xqn4bxx955z6npf3wh5n74nw0000gn/T/TemporaryDirectory.KbVot5/hello-skip-manifest
Apple Swift version 5.9.2 (swiftlang-5.9.2.2.56 clang-1500.1.0.2.5)

@naticio
Copy link

naticio commented Feb 6, 2024

Warning: openjdk@17 17.0.9 is already installed and up-to-date.

nat-serrano@Nats-MacBook-Pro-2 JavaVirtualMachines % java -version
openjdk version "17.0.9" 2023-10-17
OpenJDK Runtime Environment Homebrew (build 17.0.9+0)

nat-serrano@Nats-MacBook-Pro-2 JavaVirtualMachines % echo $JAVA_HOME
/opt/homebrew/opt/openjdk@17/

@marcprux
Copy link
Contributor

marcprux commented Feb 6, 2024

I think that problem was a different one that should be resolved if you skip upgrade to 0.8.3 (released today). Please try it out and if skip checkup or skip init fails, let us know.

@naticio
Copy link

naticio commented Feb 7, 2024

I tried to upgrade to 0.8.4 but didn't actually upgrade
nat-serrano@Nats-MacBook-Pro-2 ~ % skip upgrade
[✓] Check Skip Updates: 0.8.4
[✓] Upgrade Skip to 0.8.4 (3.55s)
nat-serrano@Nats-MacBook-Pro-2 ~ % skip doctor
Skip Doctor
[✓] Skip version 0.8.2 (= 0.8.2)
[✓] macOS version 13.6.1 (> 13.5.0)
[✓] Swift version 5.9.2 (> 5.9.0)
[✓] Xcode version 15.2 (> 15.0.0)
[✓] Xcode tools SDKs: 5
[✓] Homebrew version 4.2.7 (> 4.1.0)
[✓] Gradle version 8.6 (> 8.3.0)
[✓] Java version 17.0.9 (> 17.0.0)
[✓] Android Debug Bridge version 1.0.41 (> 1.0.40)
[✓] Android Studio version: 2023.1
[✓] Android SDK licenses: 2
[✓] Check Skip Updates: 0.8.4
[!] A new version is Skip (0.8.4) is available to update with: skip upgrade
[!] Skip (0.8.2) checks complete with 1 warning

@marcprux
Copy link
Contributor

marcprux commented Feb 7, 2024

Can you try running brew update and then skip upgrade again? It sounds like the Homebrew cache might not be updating automatically.

@mmmago
Copy link

mmmago commented May 6, 2024

Cannot make this work,

Capture d’écran 2024-05-06 à 17 09 25

even by setting JAVA_HOME=$(/usr/libexec/java_home -v17.0.11). Kotlin also fails.

java -version returns :

openjdk version "17.0.11" 2024-04-16
OpenJDK Runtime Environment Homebrew (build 17.0.11+0)
OpenJDK 64-Bit Server VM Homebrew (build 17.0.11+0, mixed mode, sharing)

Any inputs ?

@marcprux
Copy link
Contributor

marcprux commented May 6, 2024

As you seem to have surmised, this is the problem:

[!] Java version 1.8.0_411 (< 21.0.0) (check JAVA_HOME envrionment: /Library/Internet Plug-Ins/JavaAppletPlugin. plugin/Contents/Home)

You should remove any reference to JAVA_HOME in your ~/.zshrc or ~/.bashrc. Also, we do need JDK 21, not JDK 17. OpenJDK 21 should have been installed when you installed skip with the brew command. So if you remove JAVA_HOME from your environment and run skip checkup from a new shell (making sure that echo $JAVA_HOME does not return anything), then it should pick up the right one.

If that continues to fail, can you post the log file mentioned at the end of the command?

@mmmago
Copy link

mmmago commented May 6, 2024

I tried using JDK 17 because JDK 21 was not working as well. This is what is happening :

Capture d’écran 2024-05-06 à 17 26 45

Here is the log attached :

skip-checkup-2024-05-06T15:23:40Z.txt

@marcprux
Copy link
Contributor

marcprux commented May 6, 2024

From the log:

GRADLE>
GRADLE> ERROR: JAVA_HOME is set to an invalid directory: /opt/homebrew/opt/java
GRADLE>
GRADLE> Please set the JAVA_HOME variable in your environment to match the
GRADLE> location of your Java installation.
GRADLE>

Can you check whether the folder /opt/homebrew/opt/java exists? That should be where openjdk was installed by homebrew. You could try re-installing it with brew reinstall openjdk.

Also, was your machine upgraded from an Intel to an ARM (e.g., M1)? If so, the Homebrew installation may be an old Intel-based version, which sometimes installs the wrong architecture for packages. In these cases (which can be identified by the existence of a /usr/local/Homebrew/ directory), we've found that performing a clean Homebrew re-install can help resolve issues.

@mmmago
Copy link

mmmago commented May 27, 2024

From the log:

GRADLE>
GRADLE> ERROR: JAVA_HOME is set to an invalid directory: /opt/homebrew/opt/java
GRADLE>
GRADLE> Please set the JAVA_HOME variable in your environment to match the
GRADLE> location of your Java installation.
GRADLE>

Can you check whether the folder /opt/homebrew/opt/java exists? That should be where openjdk was installed by homebrew. You could try re-installing it with brew reinstall openjdk.

Also, was your machine upgraded from an Intel to an ARM (e.g., M1)? If so, the Homebrew installation may be an old Intel-based version, which sometimes installs the wrong architecture for packages. In these cases (which can be identified by the existence of a /usr/local/Homebrew/ directory), we've found that performing a clean Homebrew re-install can help resolve issues.

Hello, sorry for the lack of news. Trying this again :

/opt/homebrew/opt/java does not exist. Performing brew reinstall openjdk does not solve the problem.

I do use a M1 Pro machine, /usr/local/Homebrew is indeed existing. Performing a clean install, it now looks like /opt/homebrew/opt/ is existing, but not the java folder, even after re-performing brew reinstall openjdk.

EDIT : I fixed it by running :

echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zshrc

then

source ~/.zshrc

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