androidjava-native-interfacecross-compilinglibdatachannel

How To Correctly Build libdatachannel For Android


I've been trying to build libdatachannel for an Android project. I've tried both build options given:

I, however, keep getting the following error when I try to build the project in Android Studio C/C++:

ld: error: ../../../../libs/libdatachannel/libdatachannel.a(wstransport.o) is incompatible with aarch64linux.

Would you advise on how to get it working? How can I build it so that I get ARM builds for Android?


Solution

  • Answered here

    It looks like libdatachannel is not built for the required ARM64 architecture. The easiest way to build it for the right target is to use the Android NDK toolchain file, something like:

    $ cmake -B build -DUSE_GNUTLS=0 -DUSE_NICE=0 -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=[Path to the NDK]/build/cmake/android.toolchain.cmake -DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM=[min SDK version]