Help linking the full C++ library to an android project

I need to use the full C++ version of MAVSDK on android, so I’m trying to link the library with a different C++ library that contains app-specific code and JNI Calls.
As the dockcross scripts don’t work on windows, I’ve compiled MAVSDK on a seperate linux machine to a file, and am attempting to link it. The “MAVSDK Installed Locally” category of the documentation seems incomplete, and I don’t have much experience with CMakeLists, so I would appreciate help with linking the library. I’ve used include_directories to add the header files from the GitHub release and that seems to work fine, but isn’t enough to compile.

If there’s a better way to use the full C++ api on Android or I’m missing something, please let me know, and apologies for my inexperience. Thanks for your time.

I am newly using mavsdk develop kit.
Can you tell me how to generate file?

Sadly it has been a while and I do not remember much about this project. Lucky, I wrote down the steps. I can’t vouch for if they’re still accurate, however.

Compiling MAVSDK from source

You’ll need a Linux device or virtual machine to easily compile MAVSDK. You will need to clone the MAVSDK Github, and then combine the steps to build the server for android with the steps to build the whole library. You will need docker to compile for Android.

Assuming you have the cloned repository open, and docker installed, the following should work:

sudo docker run --rm dockcross/android-arm > ./dockcross
sudo chmod +x ./dockcross
sudo ./dockcross cmake -DCMAKE_BUILD_TYPE=Debug -Bbuild/android-arm -H.
sudo /dockcross cmake --build build/android-arm -j8

You’ll find your built library under build/android-arm/src/core/

1 Like

Hi, I use your method to generate and put it in Android Studio.
But it always appears “Build command failed”.
Do you know what it cause?

Sorry I missed your message, do you still need help? If so, please provide a bit more information as to what you’re trying and what’s going wrong.

I solved it.
Thank you