Skip to content

Update android example to use Starlark version of android_ndk_repository #2417

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

Merged
merged 5 commits into from
Jan 16, 2024

Conversation

daivinhtran
Copy link
Contributor

@daivinhtran daivinhtran commented Jan 11, 2024

The native version of android_ndk_repository rule no longer work with the newer ndk versions.

When I set ANDROID_NDK_HOME to /usr/local/vinhdaitran/Android/Sdk/ndk/26.1.10909125, the rule expects a different structure from the Android NDK path.

ERROR: /usr/local/vinhdaitran/github/rules_rust/examples/android/WORKSPACE.bazel:67:23: fetching android_ndk_repository rule //external:androidndk: java.io.IOException:
Expected directory at /usr/local/vinhdaitran/Android/Sdk/ndk/26.1.10909125/platforms but it is not a directory or it does not exist.
Unable to read the Android NDK at /usr/local/vinhdaitran/Android/Sdk/ndk/26.1.10909125, the path may be invalid. Is the path in android_ndk_repository() or ANDROID_NDK_HOME set correctly?
If the path is correct, the contents in the Android NDK directory may have been modified.

Using the Starlark version of the rule, as recommended in https://bazel.build/reference/be/android#android_ndk_repository, fixes the issue.

cc: @keith

@daivinhtran daivinhtran force-pushed the use-rules_android_ndk branch from 9ffd87b to 438f278 Compare January 11, 2024 20:03
@keith
Copy link
Member

keith commented Jan 11, 2024

fine with me, but CI might only have old versions

@daivinhtran
Copy link
Contributor Author

daivinhtran commented Jan 11, 2024

fine with me, but CI might only have old versions

@keith do you happen to know the version CI is using? and how to update it?

@katre
Copy link
Member

katre commented Jan 11, 2024

You need to set the ANDROID_NDK_HOME env correctly in the config file. See rules_android_ndk as an example.

@daivinhtran daivinhtran force-pushed the use-rules_android_ndk branch from 335ab50 to 21753c3 Compare January 11, 2024 21:04
@daivinhtran
Copy link
Contributor Author

Thanks @katre for the reference!

@daivinhtran daivinhtran changed the title Update android example to use starlark version of android_ndk_repository Update android example to use Starlark version of android_ndk_repository Jan 11, 2024
Copy link
Collaborator

@UebelAndre UebelAndre left a comment

Choose a reason for hiding this comment

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

One small request but otherwise looks good to me!

@daivinhtran daivinhtran enabled auto-merge (squash) January 16, 2024 03:37
@daivinhtran daivinhtran merged commit d48f731 into bazelbuild:main Jan 16, 2024
@daivinhtran daivinhtran deleted the use-rules_android_ndk branch January 16, 2024 03:51
daivinhtran pushed a commit to daivinhtran/rules_rust that referenced this pull request Jan 17, 2024
…ory (bazelbuild#2417)

The native version of `android_ndk_repository` rule no longer work with
the newer ndk versions.

When I set `ANDROID_NDK_HOME` to
`/usr/local/vinhdaitran/Android/Sdk/ndk/26.1.10909125`, the rule expects
a different structure from the Android NDK path.
```
ERROR: /usr/local/vinhdaitran/github/rules_rust/examples/android/WORKSPACE.bazel:67:23: fetching android_ndk_repository rule //external:androidndk: java.io.IOException:
Expected directory at /usr/local/vinhdaitran/Android/Sdk/ndk/26.1.10909125/platforms but it is not a directory or it does not exist.
Unable to read the Android NDK at /usr/local/vinhdaitran/Android/Sdk/ndk/26.1.10909125, the path may be invalid. Is the path in android_ndk_repository() or ANDROID_NDK_HOME set correctly?
If the path is correct, the contents in the Android NDK directory may have been modified.
```

Using the Starlark version of the rule, as recommended in
https://bazel.build/reference/be/android#android_ndk_repository, fixes
the issue.

cc: @keith
daivinhtran pushed a commit to daivinhtran/rules_rust that referenced this pull request Jan 17, 2024
Drop import macro (bazelbuild#2411)

As discussed over at
bazelbuild#2383

Fix rustfmt toolchains when consuming rules_rust with bzlmod. (bazelbuild#2410)

Fixes bazelbuild#2260

Provide a better error message when trying to generate rust-project.json (bazelbuild#2196)

Currently when trying to generate a `rust-project.json`, if there aren't
actually any Rust targets defined, the script mysteriously fails.

This adds a better error message.

Update android example to use Starlark version of android_ndk_repository (bazelbuild#2417)

The native version of `android_ndk_repository` rule no longer work with
the newer ndk versions.

When I set `ANDROID_NDK_HOME` to
`/usr/local/vinhdaitran/Android/Sdk/ndk/26.1.10909125`, the rule expects
a different structure from the Android NDK path.
```
ERROR: /usr/local/vinhdaitran/github/rules_rust/examples/android/WORKSPACE.bazel:67:23: fetching android_ndk_repository rule //external:androidndk: java.io.IOException:
Expected directory at /usr/local/vinhdaitran/Android/Sdk/ndk/26.1.10909125/platforms but it is not a directory or it does not exist.
Unable to read the Android NDK at /usr/local/vinhdaitran/Android/Sdk/ndk/26.1.10909125, the path may be invalid. Is the path in android_ndk_repository() or ANDROID_NDK_HOME set correctly?
If the path is correct, the contents in the Android NDK directory may have been modified.
```

Using the Starlark version of the rule, as recommended in
https://bazel.build/reference/be/android#android_ndk_repository, fixes
the issue.

cc: @keith

Allow ~ in repository names (bazelbuild#2427)

Fixes bazelbuild#2426

Prepare rust rules for Starlark CcToolchainInfo. (bazelbuild#2424)

bazelbuild#2425
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.

4 participants