简体   繁体   English

在Android studio中添加ZXing android项目作为库

[英]Add ZXing android project as library in android studio

I am making an app in android studio that uses a bar code scanner. 我在android studio中使用条形码扫描仪制作应用程序。 I am using the Google ZXing lib. 我正在使用Google ZXing lib。 I downloaded the zip, opened the project and added the core.jar file as instructed but the tutorial was for eclipse and there is no option to add as library in android studio. 我下载了zip,打开了项目并按照说明添加了core.jar文件,但教程是eclipse,没有选项在android studio中添加为库。 so I am stuck on how to add it. 所以我被困在如何添加它。 any help would be greatly appreciated :) 任何帮助将不胜感激 :)

Simple way with mvn repo: 使用mvn repo的简单方法:

dependencies {
   compile 'com.google.zxing:core:3.0.0'
}

The more work version without mvn repo: 没有mvn repo的工作版本越多:

dependencies {
   compile files('./libs/zxing/core.jar')
}     

So whichever version you pick, look for the dependencies block in your build.gradle, then add in the appropriate compile line. 因此,无论选择哪个版本,都要在build.gradle中查找依赖项块,然后添加相应的编译行。 Remember to add it into the build.gradle for your app module, not the root build.gradle. 请记住将其添加到app模块的build.gradle中,而不是root build.gradle。

Sample directory layout: /approot 示例目录布局:/ approot

/approot/build.gradle /approot/build.gradle

/approot/myfancyapp /为approot / myfancyapp

/approot/myfancyapp/build.gradle <--- this one! /approot/myfancyapp/build.gradle <---这个!

/approot/myfancyapp/libs/zxing/core.jar <--- put the jar here or any path, just an example. /approot/myfancyapp/libs/zxing/core.jar <---把jar放在这里或任何路径,只是一个例子。

如果将编译文件('libs / core.jar')添加到build.gradle,则唯一需要做的就是单击工具栏中的“使用Gradle文件同步项目”按钮。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM