Zxing 2.2 在 Eclipse 中作为库项目(不是 .jar)导入
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19268159/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Zxing 2.2 import as a library project(not .jar) in eclipse
提问by Santosh
I have downloaded the zxing 2.2 code from the below link
我已经从下面的链接下载了 zxing 2.2 代码
https://code.google.com/p/zxing/downloads/list
https://code.google.com/p/zxing/downloads/list
My requirement is to import the "core" project into eclipse and add few code into it. then mark it to be library project.
我的要求是将“核心”项目导入 eclipse 并在其中添加一些代码。然后将其标记为库项目。
I want to include this library project into barcode scanner sample app and use the barcode scanner app as library from my project.
我想将此库项目包含到条形码扫描仪示例应用程序中,并将条形码扫描仪应用程序用作我项目中的库。
回答by Santosh
Solved
解决了
prerequisties download latest zxing package.
先决条件 下载最新的 zxing 包。
Process 1
过程1
- create a java project in eclipse.and name it to something like ZxingCore.
- copy and paste complete src folder inside core folder.
- In case you need to edit any code, you can do it. otherwise skip this step.
- Java library is ready to be used.
- 在 eclipse. 中创建一个 java 项目并将其命名为类似 ZxingCore 的名称。
- 将完整的 src 文件夹复制并粘贴到核心文件夹中。
- 如果您需要编辑任何代码,您可以这样做。否则跳过这一步。
- Java 库已准备好使用。
[Note: Compile Java project using Java 1.6 to get rid of run time exceptions]
[Note: Compile Java project using Java 1.6 to get rid of run time exceptions]
Process 2
过程2
- In eclipse select Create a android project from existing source.
- browse your zip file for android folder[this is a sample project bundeled with the library] your project should be imported with few errors
- The actual core library is missing, We should add the ZxingCore library from process 1
- right click project -> properties -> JavaBuildPath(from left pane) -> project tab -> add -> check ZxingCore - Ok.
- All the errors should have gone now. it time to make the barcode scanner app to be a library project
- right click project -> properties -> android(from left pane) -> check isLibrary -> apply -> OK.
- Now you will get errors in some switch case statements. Convert the problematic switch case statements to it..elseif
- Your library project is ready
- for those who want to run the barcode scanner as a stand alone app skip the steps 5,6,7,8
- 在 eclipse 中选择 Create a android project from existing source。
- 浏览您的 zip 文件以查找 android 文件夹[这是一个与库捆绑在一起的示例项目]您的项目应该被导入并且几乎没有错误
- 缺少实际的核心库,我们应该从流程 1 中添加 ZxingCore 库
- 右键单击项目 -> 属性 -> JavaBuildPath(从左窗格) -> 项目选项卡 -> 添加 -> 检查 ZxingCore - 好的。
- 现在所有的错误都应该消失了。是时候让条码扫描仪应用成为图书馆项目了
- 右键单击项目 -> 属性 -> android(从左窗格) -> 检查 isLibrary -> 应用 -> 确定。
- 现在你会在一些 switch case 语句中得到错误。将有问题的 switch case 语句转换为它..elseif
- 您的库项目已准备就绪
- 对于想要将条码扫描仪作为独立应用程序运行的用户,请跳过步骤 5、6、7、8