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

Android ndk example app doesn't seem to build to missing JNI headers while mobile-install works fine #470

Open
prasadpamidi opened this issue Jun 16, 2024 · 0 comments

Comments

@prasadpamidi
Copy link

Hi,

I am trying to build cpp with ndk for android project and started noticing issues while building. I noticed the same issue is happening in examples repository as well with ndk example...

Ran the below command:

bazel build //app/src/main:app --fat_apk_cpu=x86 --android_crosstool_top=@androidndk//:toolchain

And noticing the below issue in the command prompt.

Starting local Bazel server and connecting to it...
WARNING: For repository 'rules_jvm_external', the root module requires module version [email protected], but got [email protected] in the resolved dependency graph.
DEBUG: /private/var/tmp/_bazel_prasadpamidi/f649ff770c75e43e391c14e7c6ebc48c/external/rules_jvm_external~/private/extensions/maven.bzl:154:14: The maven repository 'maven' is used in two different bazel modules, originally in '' and now in 'protobuf'
DEBUG: /private/var/tmp/_bazel_prasadpamidi/f649ff770c75e43e391c14e7c6ebc48c/external/rules_jvm_external~/private/extensions/maven.bzl:154:14: The maven repository 'maven' is used in two different bazel modules, originally in '' and now in 'protobuf'
DEBUG: /private/var/tmp/_bazel_prasadpamidi/f649ff770c75e43e391c14e7c6ebc48c/external/rules_jvm_external~/private/extensions/maven.bzl:154:14: The maven repository 'maven' is used in two different bazel modules, originally in '' and now in 'protobuf'
WARNING: /private/var/tmp/_bazel_prasadpamidi/f649ff770c75e43e391c14e7c6ebc48c/external/rules_android~/tools/android/BUILD:271:6: in alias rule @@rules_android~//tools/android:dexsharder: Target '@@rules_android~//tools/android:dexsharder' violates visibility of target '@@bazel_tools//src/tools/android/java/com/google/devtools/build/android/dexer:DexFileSplitter'. Continuing because --nocheck_visibility is active
INFO: Analyzed target //app/src/main:app (368 packages loaded, 17520 targets configured).
INFO: From Building external/rules_jvm_external~/private/tools/java/com/github/bazelbuild/rules_jvm_external/zip/libzip.jar (1 source file) [for tool]:
warning: [options] source value 8 is obsolete and will be removed in a future release
warning: [options] target value 8 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
INFO: From Building external/rules_jvm_external~/private/tools/java/com/github/bazelbuild/rules_jvm_external/jar/AddJarManifestEntry.jar (1 source file) [for tool]:
warning: [options] source value 8 is obsolete and will be removed in a future release
warning: [options] target value 8 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
INFO: From Building external/bazel_tools/src/tools/android/java/com/google/devtools/build/android/dexer/DexFileSplitter.jar (5 source files) and running annotation processors (AutoValueProcessor) [for tool]:
warning: [options] source value 8 is obsolete and will be removed in a future release
warning: [options] target value 8 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
ERROR: /Users/prasadpamidi/examples/android/ndk/app/src/main/BUILD.bazel:17:11: Compiling app/src/main/cpp/native-lib.cpp failed: (Exit 1): cc_wrapper.sh failed: error executing CppCompile command (from target //app/src/main:jni_lib) external/bazel_tools~cc_configure_extension~local_config_cc/cc_wrapper.sh -U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -Wunused-but-set-parameter -Wno-free-nonheap-object ... (remaining 21 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
app/src/main/cpp/native-lib.cpp:1:10: fatal error: 'jni.h' file not found
#include <jni.h>
         ^~~~~~~
1 error generated.
Target //app/src/main:app failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 30.667s, Critical Path: 3.90s
INFO: 44 processes: 11 internal, 30 darwin-sandbox, 3 worker.

This issue isn't happening when i run bazel mobile-install //app/src/main:app --fat_apk_cpu=x86 --start_app --android_crosstool_top=@androidndk//:toolchain.

Am I doing something wrong? is the cpp with ndk not supposed to work with build?

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

1 participant