Skip to content

hello-swift-java: JAVA_HOME in Android Studio builds #23

@carson-katri

Description

@carson-katri

I tried to build the basic hello-swift-java-hashing-app example through Android Studio. However, it fails to build with a missing JAVA_HOME path.

error: 'hashing-lib': Invalid manifest (compiled with: ["~/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2025-10-16-a.xctoolchain/usr/bin/swiftc", "-vfsoverlay", "/var/folders/47/kzjdq9x56dj77sc4xng5nc180000gp/T/TemporaryDirectory.Va6pCT/vfs.yaml", "-L", "~/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2025-10-16-a.xctoolchain/usr/lib/swift/pm/ManifestAPI", "-lPackageDescription", "-Xlinker", "-rpath", "-Xlinker", "~/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2025-10-16-a.xctoolchain/usr/lib/swift/pm/ManifestAPI", "-target", "arm64-apple-macosx14.0", "-I", "~/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2025-10-16-a.xctoolchain/usr/lib/swift/macosx/testing", "-L", "~/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2025-10-16-a.xctoolchain/usr/lib/swift/macosx/testing", "-plugin-path", "~/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2025-10-16-a.xctoolchain/usr/lib/swift/host/plugins/testing", "-sdk", "/Applications/Xcode-26.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX26.0.sdk", "-F", "/Applications/Xcode-26.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks", "-F", "/Applications/Xcode-26.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/PrivateFrameworks", "-I", "/Applications/Xcode-26.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib", "-L", "/Applications/Xcode-26.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib", "-swift-version", "6", "-I", "~/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2025-10-16-a.xctoolchain/usr/lib/swift/pm/ManifestAPI", "-sdk", "/Applications/Xcode-26.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX26.0.sdk", "-package-description-version", "6.2.0", "~/Downloads/swift-android-examples/hello-swift-java/hashing-lib/Package.swift", "-o", "/var/folders/47/kzjdq9x56dj77sc4xng5nc180000gp/T/TemporaryDirectory.9yfWJ3/hashing-lib-manifest"])
main/Package.swift:29: Fatal error: Please set the JAVA_HOME environment variable to point to where Java is installed.

I have a couple of questions about the setup:

  • Should the build.gradle set the JAVA_HOME, or should this be set globally for my system?
  • Should it be the JAVA_HOME from Android Studio, or the one from sdkman used to build the local packages?

Sorry if I'm missing something obvious, I'm not very familiar with Android development.

When building the .aar from the command line with ./gradlew :hello-swift-java-hashing-lib:assembleRelease, it successfully builds with JAVA_HOME set to the sdkman path.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions