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

Abierto
#470 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
android, cpp

Línea de trabajo

Empieza por app/src/main/BUILD.bazel y app/src/main/cpp/native-lib.cpp, luego reproduce el fallo con el comando bazel build indicado y compáralo con bazel mobile-install. Se considera terminado cuando el ejemplo de Android NDK se compila correctamente con //app/src/main:app y ya no informa de que falta jni.h.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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?

Lenguaje dominante
Starlark
Estrellas
958
Forks
582
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de bazelbuild/examples

Todos los issues de bazelbuild/examples

Issues similares

Más issues de Build System

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.