本机库(.so文件)不会添加到Android项目 [英] Native libraries (.so files) are not added to an android project

查看:286
本文介绍了本机库(.so文件)不会添加到Android项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 sqlitecipher 库要求使用本机库。他们的教程很简单,但它并没有为我工作。每次我收到以下错误:

I'm trying to use sqlitecipher library which requires using native libraries. Their tutorial is very simple but it doesn't work for me. Every time I get the following error:

FATAL EXCEPTION: main
        java.lang.UnsatisfiedLinkError: Couldn't load stlport_shared from loader dalvik.system.PathClassLoader[dexPath=/data/app/org.example.test-2.apk,libraryPath=/data/app-lib/org.example.test-2]: findLibrary returned null
        at java.lang.Runtime.loadLibrary(Runtime.java:365)
        at java.lang.System.loadLibrary(System.java:535)
        at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:141)
        at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:136)

表示。所以在编译过程中没有附加文件。

it means .so files were not attached during compilation.

3的所有文件都存储在/库/ armeabi /目录。

all 3 files are stored in /libs/armeabi/ directory.

我认为这个问题是我用maven来管理依赖关系(采用Android工作室反正进行建设)。接下来的尝试 - 包括那些库到Maven的依赖关系。据<一href="https://$c$c.google.com/p/maven-android-plugin/wiki/NativeLibsAsDependencies">documentation这是pretty的方便。我找不到他们在一个公共仓库,所以我用&LT;范围&GT;系统&LT; /范围&GT; 与标记。他们是可见的,但没有奏效。后来发现<一href="http://grokbase.com/t/gg/maven-android-developers/1342a8mh4h/native-libraries-from-local-path">this链接,据说范围制度将无法正常工作,尝试添加这些库到本地存储库中使用

I assumed that the problem is that I use maven to manage dependencies (building is performed using Android Studio anyways). The next try - include those libraries into maven dependencies. According documentation it is pretty easy. I couldn't find them in a public repository so I used <scope>system</scope> with a tag. They were visible but it didn't work. Later found this link where it is said that scope "system" won't work, tried adding those libraries into local repository using

mvn install:install-file -DgroupId=net.sqlitecipher -DartifactId=stlport_shared -Dversion=1.0 -Dfile=libstlport_shared.so -Dpackaging=so -DgeneratePom=true

到底 - 它不工作

in the end - it didn't work.

另外,我看到这个<一href="http://stackoverflow.com/questions/16683775/include-so-library-in-apk-in-android-studio/17131418#17131418">topic,也许这是一个解决方案,但我不使用当前摇篮。有没有一种方法,包括.so文件到APK没有从行家移动到摇篮?

Also I saw this topic, probably this is a solution but I don't use gradle currently. Is there a way to include .so files into the apk without moving from maven to gradle?

据我了解的Andr​​oid Studio使用摇篮内部建立的apk,所以使用Maven我所有的努力都是没有用的,直到他们开始支持本地库,对吗?我也曾尝试建设项目的IntelliJ IDEA Cardea(13.0),可惜没有成功。

As I understood Android Studio uses gradle internally to build apks, so all my efforts with maven are useless until they start supporting native libraries, am I right? I have also tried building the project with Intellij IDEA Cardea (13.0), unfortunately without any success.

推荐答案

只要本地库在/库/ armeabi /所有你需要做的就是正确配置的Andr​​oid插件。事情是这样的:

As soon as the native libs are in /libs/armeabi/ all you have to do is to configure the android plugin properly. Something like this:

<plugin>
    <groupId>com.jayway.maven.plugins.android.generation2</groupId>
    <artifactId>android-maven-plugin</artifactId>
    <configuration>
         <nativeLibrariesDirectory>${project.basedir}/libs</nativeLibrariesDirectory>
         ...
    </configuration>
    <extensions>true</extensions>
</plugin>

这篇关于本机库(.so文件)不会添加到Android项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆