I had a build question, specifically using the Maven build environment. I am building an Android library using the Android NDK (r10e). I am building for Android 6.0 (API 23). Although after I use this library in my main project and drop it on my tablet, I get the following error:
java.lang.UnsatisfiedLinkError: dlopen failed: library "libgnustl_shared.so" not found
My Application.mk is:
APP_ABI := all
APP_STL:=gnustl_shared
APP_CPPFLAGS += -std=c++11
My maven file looks like the following:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>myParent</artifactId>
<groupId>com.test.android</groupId>
<version>1.05</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>myNativeLib</artifactId>
<packaging>so</packaging>
<name>testNativeLib</name>
<properties>
<android.ndk.args>V=1 -B NDK_DEBUG=1 -j8</android.ndk.args>
<arch>armeabi-v7a armeabi</arch> <!-- TODO add more arch types -->
<mavenAntrunPluginVersion>1.8</mavenAntrunPluginVersion>
<includes.version>1.0.6</includes.version>
<sonar.sources>src,pom.xml</sonar.sources>
</properties>
<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-webdav</artifactId>
<version>1.0-beta-2</version>
</extension>
</extensions>
<plugins>
<plugin>
<groupId>com.simpligility.maven.plugins</groupId>
<artifactId>android-ndk-maven-plugin</artifactId>
<version>1.0.1-SNAPSHOT</version>
<extensions>true</extensions>
<configuration>
<target>${project.artifactId}</target>
<finalLibraryName>${project.artifactId}</finalLibraryName>
<ndkPath>${android.ndk.path}</ndkPath>
<!-- so jenkins parameter -Dandroid.ndk.path actually works. -->
<applicationMakefile>src/main/cpp/Application.mk</applicationMakefile>
<makefile>src/main/cpp/Android.mk</makefile>
<architectures>${arch}</architectures>
<additionalCommandline>${android.ndk.args}</additionalCommandline>
<librariesOutputDirectory>${project.build.directory}/ndk-libs</librariesOutputDirectory>
<objectsOutputDirectory>${project.build.directory}/ndk-obj</objectsOutputDirectory>
<headerFilesDirectives>
<headerFilesDirective>
<directory>${basedir}/src/main/cpp</directory>
<includes>
<include>**\/*.hpp</include>
</includes>
</headerFilesDirective>
</headerFilesDirectives>
</configuration>
</plugin>
</plugins>
</build>
<!-- placeholder -->
<profiles>
<profile>
<id>release</id>
<activation>
<property>
<name>performRelease</name>
</property>
</activation>
<properties>
<android.ndk.args>V=1 -B -j8</android.ndk.args>
</properties>
</profile>
</profiles>
</project>
Now, this generates the .so that I want and throws it into my .m2 (repository) folder. I then go to my main project and it builds just fine. Its after I drop it on the tablet and start it (where it tries to loadLibrary) is where it fails. I have not seen anything on SO on this issue specifically in this setup. Closest thing I've seen is this dead thread:
Android Studio: java.lang.UnsatisfiedLinkError: dlopen failed
which was not very helpful. Its important to note that this work on my Android 4.0 implementation (API 18). Just not on 6.0. Looking at the apk, I can see the .so in
lib\armeabi-v7a\testNativeLib.so
Any thoughts? I'm stuck here.
