Can not build android_library with embedded so file (using ndk)
See original GitHub issueIf possible, provide a minimal example to reproduce the problem:
Created a simple android_library which encloses java and needed so file at: https://github.com/spinorx/bazel_android_test
doing: bazel build --config android :and_lib -s
Getting compilation error:
ERROR: /Users/param/bazel_android_test/BUILD:3:1: C++ compilation of rule '//:liband_cpp.so' failed (Exit 1).
clang: error: unknown argument: '-m<platform_for_version_min>-version-min=11.0'
Target //:and_lib failed to build
I am trying to get android ndk to build so file using libc++ using bazel. (Note that I has to push include under libcxx for libc++ because of: https://github.com/bazelbuild/bazel/issues/3923)
Environment info
-
Operating System: Mac OS 10.12.6
-
Bazel version (output of
bazel info release
): release 0.6.1-homebrew
Have you found anything relevant by searching the web?
(e.g. StackOverflow answers,
GitHub issues,
email threads on the bazel-discuss
Google group)
Anything else, information or logs or outputs that would be helpful?
(If they are large, please upload as attachment or provide link).
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:13 (6 by maintainers)
Top Results From Across the Web
How to include *.so library in Android Studio? - Stack Overflow
Please try first the jniLibs folder solution. This tasks should be put into your app/library gradle.build file. – nenick. Sep 16, 2016 at...
Read more >How to Build *.so Library Files into AAR Bundle in Android ...
How to create a basic aar file? Click File > New > New Module and select Android Library: Android library. Comparing build.gradle files,...
Read more >Build a Native Android Library or Module using NDK and CMake
CMake is an external build tool that works alongside Gradle to build your native code and it requires a build script CMakeLists.txt to...
Read more >Using Native Libraries - Xamarin - Microsoft Learn
Learn how to use, debug, and deploy Native Libaries via the standard PInvoke mechanism on Xamarin.Android.
Read more >Android.mk - NDK - Android Developers
An Android.mk file must begin by defining the LOCAL_PATH variable: ... If you do so, keep in mind that the NDK build system...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
So just to summarize, the issue here is that “building for Android” can mean multiple things and it’s not reasonable for protobuf team to keep an exhaustive list of all of them. (I’d argue it’s also not reasonable for Bazel team to keep an exhaustive list, since users can define their own Android crosstools. But maybe that’s another discussion.)
@spinorx , you can try adding this to the bottom of your WORKSPACE:
This will override the value of
//external:android/crosstool
from@android_ndk//:gnu-libstdcpp
to@android_ndk//:toolchain-libcpp
. Then you can use --android_crosstool_top=//external:android/crosstool.This solution is essentially “make the user specify that their crosstool is an android crosstool”.
Closing as Adam has provided a solution, and we are moving towards a new configurability solution.