如何打包并链接OpenCV的binares和OpenCV的Java SDK为Android工作室?
试图开始使用OpenCV的Java SDK的Android上的Studio中创建一个应用程序打靶14 - 19
Trying to get started with OpenCV Java SDK on Android Studio creating an app targetting 14 - 19.
我继@Paito这里定义的步骤:
http://stackoverflow.com/a/20600674/1291489
I'm following steps defined by @Paito here: http://stackoverflow.com/a/20600674/1291489
1)在一个.jar我包库
1) I package libs in a .jar
2)添加依赖关系:
...
依赖{
2) Add dependencies: ... dependencies {
//OpenCV
compile files('libs/opencv-2.4.8.jar')
compile project(':app:libs:opencv')
}
3)复制OpenCV的java文件夹
3) Copy the OpenCV java folder
4)创建并编定的OpenCV的build.gradle(同引用来源)
4) Create and fix build.gradle for OpenCV (same as referenced source)
5)尽量使用库
import org.opencv.android.OpenCVLoader;
...
if (!OpenCVLoader.initDebug()) {}
结果:
应用程序建立并运行,但我得到了以下异常:
Results: App builds and runs but I get the following exception:
03-19 19:54:46.144 D/OpenCV/StaticHelper﹕ Trying to get library list
03-19 19:54:46.144 E/OpenCV/StaticHelper﹕ OpenCV error: Cannot load info library for OpenCV
03-19 19:54:46.144 D/OpenCV/StaticHelper﹕ Library list: ""
03-19 19:54:46.144 D/OpenCV/StaticHelper﹕ First attempt to load libs
03-19 19:54:46.144 D/OpenCV/StaticHelper﹕ Trying to init OpenCV libs
03-19 19:54:46.144 D/OpenCV/StaticHelper﹕ Trying to load library opencv_java
03-19 19:54:46.144 D/OpenCV/StaticHelper﹕ Cannot load library "opencv_java"
03-19 19:54:46.154 W/System.err java.lang.UnsatisfiedLinkError: Couldn't load opencv_java: findLibrary returned null
无法看到什么是错在这里。我试图打包.jar文件的每一个可能的方式和调整重复步骤中的至少10倍。
我也试过结构:
-opencv.jar
-libs
-armeabi-v7a
-(.so files)
我测试的三星GS3Mini和Genymotion 4.1.1,并获得在两个相同的结果。两者都运行OpenCV的经理和样品。
I am testing on a Samsung GS3Mini and Genymotion 4.1.1, and getting same results on both. Both are running OpenCV Manager and samples.
您应该添加* .so文件, /主/ jniLibs
文件夹,如果你的插件的gradle为0.7 .2+并添加OpenCV的Java作为库,请按照我在这里盖的步骤。
You should add the *.so files in /main/jniLibs
folder if your gradle plugin is 0.7.2+ and add the opencv java as library, follow the steps which I covered here.
How使用gradle这个构建工具使用OpenCV的android系统工作室?