如何复制或使用本机库与Android Studio的摇篮打造? [英] How to copy or use native libs with Android Studio Gradle build?

查看:137
本文介绍了如何复制或使用本机库与Android Studio的摇篮打造?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个本地库

所谓libparser.so /库/ armeabi文件夹 和相关联的jar文件。

/libs/armeabi folder called libparser.so and an associated jar file.

我改变了摇篮构建文件包括JAR文件,该文件seemsm很容易(MYNEWJAR):

I changed the gradle build file to include the jar file, which seemsm to be easy (MYNEWJAR):

dependencies {
    compile files('libs/android-support-v4.jar', 'libs/MYNEWJAR.jar')
}

但是,当我运行的应用程序,我认为它无法找到本地库:

But when I run the app, I think it cannot find the native lib:

E/AndroidRuntime(22569): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load parser from loader dalvik.system.PathClassLoader[dexPath=/data/app/com.hybris.mobile.history-1.apk,libraryPath=/data/app-lib/com.hybris.mobile.history-1]: findLibrary returned null
E/AndroidRuntime(22569):    at java.lang.Runtime.loadLibrary(Runtime.java:365)
E/AndroidRuntime(22569):    at java.lang.System.loadLibrary(System.java:535)
E/AndroidRuntime(22569):    at com.senstation.android.pincast.Pincast.<clinit>(Pincast.java:1299)
E/AndroidRuntime(22569):    ... 17 more

你能帮我把构建文件直接,因此将包括本地库?这似乎是在Eclipse中自动发生,但我真的想用机器人工作室。

Can you help me get the build file straight so it will include the native lib? This seems to be happening automatically on Eclipse, but i really want to use android studio.

THX! 斯文

推荐答案

嗯...我希望有人提供了一个明显的例子, 如何做一个第三方JAR文件的访问Android的工作室, 呈现出什么样的产生build.gradle文件的确切的语法 依赖子句会是什么样子,他们已经加入他们的foobar.jar后, 条目。

Hmm...I was HOPING that someone will provide a clear example, of how to make a 3rd-party JAR file accessible to Android-Studio, by showing the exact SYNTAX of what the resulting 'build.gradle' file's dependency-clause would look like, after they've added their 'foobar.jar' entry.

您知道的,是这样的:

=========

=========

dependencies {
    compile 'com.android.support:support-v4:13.0.+'
    compile 'org.somedevs.foobar:Foobar.jar'
}

=========

=========

[否则,我不站在一个雪球的机会在地狱 猜是什么的答案公布至今的真正含义。我的 INTITAL条款包含在单一的编译行......所以我 GUESS会,一要增加一个这样的行!?!?]

[Otherwise, I don't stand a snowball's chance in hell of guessing what the answers posted so far really mean. My INTITAL clause contained the single 'compile' line...so my GUESS would that one should add another such line!?!?]

编辑:是的,非常感谢,rebelious!我现在也一样,有它的工作。 取而代之的是拖/放到在Studio中的库的[,我有更多的  仅通过鼠标右键点击库的工作室,选择可靠的结果  添加为库...,复制的JAR文件到该位置,使用CMD线后]

Yes, many THANKS, rebelious! I now, too, have it working. [Instead of the 'drag/drop' onto the 'libs' in Studio, I have more reliable results by just right-clicking on 'libs' in Studio and choose "add as library...", after copying the JAR into that location, using cmd-line.]

的正确形式的依赖关系子句的形式如下:

The correct form for the dependencies clause is the form shown below:

 dependencies {
        compile 'com.android.support:support-v4:13.0.+'
        compile files ('libs/Foobar.jar')
    }

这篇关于如何复制或使用本机库与Android Studio的摇篮打造?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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