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

Fix NDK path detection #103

Merged
merged 13 commits into from
Apr 25, 2024
Merged

Fix NDK path detection #103

merged 13 commits into from
Apr 25, 2024

Conversation

ofalvai
Copy link
Contributor

@ofalvai ofalvai commented Apr 24, 2024

Checklist

  • I've read and followed the Contribution Guidelines
  • step.yml and README.md is updated with the changes (if needed)

Version

Requires a PATCH version update

Context

NDK installation and configuration has changed a lot over the years: https://github.com/android/ndk-samples/wiki/Configure-NDK-Path#the-default-ndk-location

It's also installed incorrectly on the Ubuntu 20 stack, which we fixed on Ubuntu 22. This in turn broke this step, which assumed the incorrect install location of the Ubuntu 20 stack (see #102)

Changes

Clean up and rework the NDK location detection logic. I tried to comment the code as much as possible to preserve the reasoning.

Investigation details

Decisions

inputs:
- content: |-
#!/usr/bin/env bash
sdkmanager --uninstall "extras;android;m2repository"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was only a problem in very old Android Gradle Plugin versions. This even predates the support library vs. AndroidX migration thing. I don't think it's needed anymore, and it would be almost impossible to set up a working project that tests this successfully (this needs an old AGP version, which needs an old Gradle version, which needs JDK8, etc.)

main.go Show resolved Hide resolved
@ofalvai ofalvai marked this pull request as ready for review April 25, 2024 09:40
@ofalvai ofalvai requested a review from lpusok April 25, 2024 11:01
if androidHome := envRepo.Get("ANDROID_HOME"); androidHome != "" {
// The most modern way is to install NDK versions side-by-side at $ANDROID_HOME/ndk/version
// This is what `sdkmanager` does when installing a specific version (`sdkmanager "ndk;26.3.11579264"`).
ndkPath := filepath.Join(androidHome, "ndk", requestedNDKVersion)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will only work if specifying the exact version number right? Dunno if it is a problem

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole thing only works with exact numbers because that's what is recorded in source.properties and that's what sdkmanager --install expects unfortunately.

@ofalvai ofalvai merged commit 6f93547 into master Apr 25, 2024
1 check passed
@ofalvai ofalvai deleted the ofalvai/fix-ndk-detection branch April 25, 2024 14:02
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

Successfully merging this pull request may close these issues.

3 participants