Android的工作室0.2.6和ZBar项目设置 [英] Android Studio 0.2.6 and ZBar project setup
问题描述
我使用的是最新的Android 0.2.6工作室和最新ZBar的Android SDK。我迄今所做的:
- 创建一个名为QRTest一个全新的项目
- 创建一个文件夹,名为库在我的项目
- 把Zbar libs目录的内容到我的项目文件夹
- 右键单击该文件zbar.jar在我的项目,并添加为库
-
在我的build.gradle文件,编辑它,以便它现在是:
依赖性{
编译com.android.support:support-v4:13.0.0
编译文件(库/ zbar.jar')
} - 基本上复制从ZBar Android SDK中的例子的例子code到我自己的项目。
- 项目编译并运行良好(0个错误,0警告),但它崩溃时运行。该日志显示:
16 09-01:06:02.026:W / dalvikvm(7050):异常
Ljava /朗/的UnsatisfiedLinkError;在初始化抛出
LNET / sourceforge上/ zbar /图象扫描;
09-01 16:06:02.036:
E / AndroidRuntime(7050):java.lang.UnsatisfiedLinkError中:产生的原因:
无法加载库:link_image [1891] 209无法加载所需
库libiconv.so'为'libzbarjni.so(load_library [1093]:库
libiconv.so'未找到)
16 09-01:06:02.036:E / AndroidRuntime(7050):
在net.sourceforge.zbar.ImageScanner。(来源不明)
块引用>在我MainActivity的code来看,这似乎是在这里死去:
/ *实例吧code扫描仪* /
扫描仪=新图象扫描();这似乎在暗示我,不知怎的,我还没有正确导入我的Zbar库文件。任何帮助就如何得到这个非常简单的例子并打算将AP preciated!
只是要注意,如果我使用Android工作室从ZBar Android SDK中的例子导入一个新的项目,它编译并运行良好。但是,使用旧的蚂蚁构建系统。我宁愿使用新gradle这个构建系统,所以这就是为什么我试图导入ZBar到一个新的Android 0.2.6项目。谢谢!
另注:我尝试改变我的gradle构建以接受的答案在这里: Android的工作室Zbar 并它没有工作。
解决方案您应该添加*的.so库项目。如果你使用Android Studio和摇篮这是一个有点复杂,因为你需要打包成库罐子。在这里查看我的回答:<一href=\"http://stackoverflow.com/questions/20524669/zbar-qr-$c$c-scanner-crashing-in-android-studio/20528074#20528074\">ZBar - QR code扫描仪,Android Studio中轰然,了解更多详情。
。I am using the latest Android Studio 0.2.6 and the latest ZBar Android SDK. What I have done so far:
- Created a brand new project called QRTest
- Created a folder called libs in my project
- Put the content of the Zbar libs directory into my project folder
- Right clicked the zbar.jar file in my project and Added as a Library
In my build.gradle file, edited it so that it is now:
dependencies { compile 'com.android.support:support-v4:13.0.0' compile files('libs/zbar.jar') }
- Basically copied the example code from the ZBar android SDK example to my own project.
- The project compiles and runs fine (0 errors, 0 warnings), but it crashes upon running. The logs show:
09-01 16:06:02.026: W/dalvikvm(7050): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lnet/sourceforge/zbar/ImageScanner;
09-01 16:06:02.036: E/AndroidRuntime(7050): Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: link_image[1891]: 209 could not load needed library 'libiconv.so' for 'libzbarjni.so' (load_library[1093]: Library 'libiconv.so' not found)
09-01 16:06:02.036: E/AndroidRuntime(7050): at net.sourceforge.zbar.ImageScanner.(Unknown Source)
Looking at the code in my MainActivity, it appears to be dying here:
/* Instance barcode scanner */ scanner = new ImageScanner();
Which seems to suggest to me that somehow I havent imported my Zbar library files correctly. Any help on how to get this very basic example up and going would be appreciated!
Just to note, if I use Android Studio to import a new project from the ZBar Android SDK example, it compiles and runs fine. However, it is using the old ant build system. I would rather use the new gradle build system, so thats why I'm trying to import ZBar into a fresh Android 0.2.6 project. Thanks!
Another note: I tried modifying my build gradle to the accepted answer here: Android Studio Zbar and it did not work.
解决方案You should add *.so libraries to your project. If you use Android Studio and Gradle it's a little complicated because you need to pack libraries into jar. Check my answer here: ZBar - QR Code Scanner, crashing in Android Studio to see more details.
这篇关于Android的工作室0.2.6和ZBar项目设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!