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

fatal error: jni.h: No such file or directory with Bazel@HEAD #381

Closed
sgowroji opened this issue Dec 11, 2023 · 2 comments · Fixed by #398
Closed

fatal error: jni.h: No such file or directory with Bazel@HEAD #381

sgowroji opened this issue Dec 11, 2023 · 2 comments · Fixed by #398
Assignees

Comments

@sgowroji
Copy link
Member

https://buildkite.com/bazel/bazel-at-head-plus-downstream/builds/3519#018c569e-3795-4226-ab3e-197736d4484f

Platform : Windows, Ubuntu, MacOS

Logs:

app/src/main/cpp/native-lib.cpp:1:10: fatal error: jni.h: No such file or directory
 #include <jni.h>
          ^~~~~~~
compilation terminated.
(02:09:02) ERROR: /var/lib/buildkite-agent/builds/bk-docker-l9gw/bazel-org-repo-root/examples/android/ndk/app/src/main/BUILD.bazel:17:11: Compiling app/src/main/cpp/native-lib.cpp failed: (Exit 1): gcc failed: error executing CppCompile command (from target //app/src/main:jni_lib)

Steps:

git clone -v https://github.com/bazelbuild/examples.git
git reset e2746bf0e3f987cc556e5188c18fec33edc1b61a --hard
export USE_BAZEL_VERSION=591d1257c51c2f997e067964878e3a9c7ee1f89c
cd /android/ndk
bazel build --noincompatible_enable_android_toolchain_resolution --fat_apk_cpu=arm64-v8a,x86 --android_crosstool_top=@androidndk//:toolchain --enable_bzlmod  //app/src/main:app

CC Greenteam @comius

@meteorcloudy
Copy link
Member

Looks like the failure is related to the changes in 5e37d3c

/cc @katre Can you please take a look?

@katre
Copy link
Member

katre commented Jan 16, 2024

As indicated in android.yml, the problem is that this example does not use the new Android platforms flags, it's using the legacy flags, which aren't supported in Bazel at HEAD.

Using Bazel 6.4.0, the build works:

$ USE_BAZEL_VERSION=6.4.0 bazel build --noincompatible_enable_android_toolchain_resolution --fat_apk_cpu=arm64-v8a,x86 --android_crosstool_top=@androidndk//:toolchain --enable_bzlmod  //app/src/main:app
INFO: Analyzed target //app/src/main:app (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //app/src/main:app up-to-date:
  bazel-bin/app/src/main/app_deploy.jar
  bazel-bin/app/src/main/app_unsigned.apk
  bazel-bin/app/src/main/app.apk
INFO: Elapsed time: 0.350s, Critical Path: 0.01s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action

I'll try updating the flags and see if that works, but last time I tried I ran into bazelbuild/rules_android#77.

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 a pull request may close this issue.

3 participants