Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

deploying android ndk dependencies to maven repositories

I have an android project that depends on a third party, binary-only JNI library. Using ant, I can just drop the .so in libs/ and the headers in jni/ and be done.

However, the rest of my android projects use maven, and I would like to be able to integrate this library into my existing maven-based projects just as I would any other library (i.e. with a <dependency /> entry, library automatically downloaded from the company server).

I have tried manually uploading the .so files using mvn deploy:deploy-file with -Dpackaging=so and -Dclassifier=armeabi, and uploaded the headers in a zip and deployed using -Dpackaging=har. But the NDK still fails to detect the library and headers.

My Android.mk is

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := test
LOCAL_LDLIBS := -llog
LOCAL_SHARED_LIBRARIES := my-dependency
LOCAL_SRC_FILES := test.cpp
include $(BUILD_SHARED_LIBRARY)

and the dependency in my pom

<dependency>
    <groupId>com.thirdparty.my-dependency</groupId>
    <artifactId>my-dependency</artifactId>
    <version>1.0</version>
    <classifier>armeabi</classifier>
    <type>so</type>
</dependency>

What would be the best way to deploy a third party library like this in maven for android?

like image 697
larvyde Avatar asked Oct 22 '22 11:10

larvyde


1 Answers

After some tinkering with the samples, I managed to get it to compile.

The deployment is fine, but it turns out I need to add

LOCAL_SHARED_LIBRARIES := $(ANDROID_MAVEN_PLUGIN_LOCAL_SHARED_LIBRARIES)
include $(BUILD_SHARED_LIBRARY)
include $(ANDROID_MAVEN_PLUGIN_MAKEFILE)

To the app's Android.mk

like image 71
larvyde Avatar answered Oct 27 '22 10:10

larvyde