question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can not build android_library with embedded so file (using ndk)

See original GitHub issue

If 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:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
aj-michaelcommented, Oct 23, 2017

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:

bind(name = "android/crosstool", actual = "@android_ndk//:toolchain-libcpp")

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”.

0reactions
jincommented, Oct 24, 2019

Closing as Adam has provided a solution, and we are moving towards a new configurability solution.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found