简体   繁体   English

Android 库:java.lang.UnsatisfiedLinkError:dlopen 失败:找不到库“libgnustl_shared.so”

[英]Android Library: java.lang.UnsatisfiedLinkError: dlopen failed: library "libgnustl_shared.so" not found

I had a build question, specifically using the Maven build environment.我有一个构建问题,特别是使用 Maven 构建环境。 I am building an Android library using the Android NDK (r10e).我正在使用 Android NDK (r10e) 构建 Android 库。 I am building for Android 6.0 (API 23).我正在为 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:我的 Application.mk 是:

APP_ABI:= all APP_ABI:= 全部

APP_STL:=gnustl_shared APP_STL:=gnustl_shared

APP_CPPFLAGS += -std=c++11 APP_CPPFLAGS += -std=c++11

My maven file looks like the following:我的 maven 文件如下所示:

<?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.现在,这会生成我想要的.so 并将其放入 my.m2(存储库)文件夹中。 I then go to my main project and it builds just fine.然后我将 go 放到我的主项目中,它构建得很好。 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 Android Studio:java.lang.UnsatisfiedLinkError:dlopen 失败

which was not very helpful.这不是很有帮助。 Its important to note that this work on my Android 4.0 implementation (API 18).需要注意的是,这项工作适用于我的 Android 4.0 实现(API 18)。 Just not on 6.0.只是不在 6.0 上。 Looking at the apk, I can see the.so in查看apk,我可以看到.so 在

lib\armeabi-v7a\testNativeLib.so

Any thoughts?有什么想法吗? I'm stuck here.我被困在这里。

Along with your library, the APK must include the STL runtime, in your case libgnustl_shared.so . 与您的库一起,APK必须包含STL运行时,在您的情况下为libgnustl_shared.so if you only have it for armeabi , this could be an explanation of your crash. 如果你只有armeabi ,这可能是你的崩溃的解释。

Another difference is that, in API 18, you must load the STL library separately from Java, it didn't handle dependencies well back then. 另一个区别是,在API 18中,您必须与Java分开加载STL库,它当时不能很好地处理依赖关系。

BTW, is your library really named testNativeLib.so ? 顺便说一下,你的库真的名为testNativeLib.so吗? Without lib prefix it won't be properly installed. 如果没有lib前缀,则无法正确安装。

Copy libs files to将 libs 文件复制到

src/main/libs src/main/libs

point libs file in the app.gradle file app.gradle 文件中的点库文件

在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 反应本机期望java.lang.UnsatisfiedLinkError:dlopen失败:“ / data / data / {package} /lib-main/libgnustl_shared.so”是32位而不是64位 - React native expection java.lang.UnsatisfiedLinkError: dlopen failed: “/data/data/{package}/lib-main/libgnustl_shared.so” is 32-bit instead of 64-bit java.lang.UnsatisfiedLinkError: dlopen failed: library &quot;/Users/...&quot; not found - java.lang.UnsatisfiedLinkError: dlopen failed: library "/Users/..." not found java.lang.UnsatisfiedLinkError: dlopen failed: library not found - java.lang.UnsatisfiedLinkError: dlopen failed: library not found Flutter 初始化失败,java.lang.UnsatisfiedLinkError: dlopen failed: library "libflutter.so" not found - Flutter initialization failed, java.lang.UnsatisfiedLinkError: dlopen failed: library "libflutter.so" not found java.lang.UnsatisfiedLinkError:dlopen 失败:找不到库“libopencv_java3.so” - java.lang.UnsatisfiedLinkError: dlopen failed: library “libopencv_java3.so” not found java.lang.UnsatisfiedLinkError:dlopen失败:找不到库“ libutils.so” - java.lang.UnsatisfiedLinkError: dlopen failed: library “libutils.so” not found AndroidRuntime:java.lang.UnsatisfiedLinkError:dlopen 失败:找不到库“libandroidicu.so” - AndroidRuntime: java.lang.UnsatisfiedLinkError: dlopen failed: library "libandroidicu.so" not found java.lang.UnsatisfiedLinkError:dlopen失败:找不到库“ libpthread.so.0” - java.lang.UnsatisfiedLinkError: dlopen failed: library “libpthread.so.0” not found java.lang.UnsatisfiedLinkError:dlopen 失败:找不到库“../../lib/libopencv_core.so” - java.lang.UnsatisfiedLinkError: dlopen failed: library "../../lib/libopencv_core.so" not found Opencv Android:java.lang.UnsatisfiedLinkError:dlopen失败:无法加载库“libopencv_java.so” - Opencv Android: java.lang.UnsatisfiedLinkError: dlopen failed: could not load library “libopencv_java.so”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM