简体   繁体   English

如何将Zxing库包含到android项目中?

[英]How to include Zxing library to android project?

I have read some answer for this question in stackoverflow, but it is not working for me. 我已经在stackoverflow中读到了这个问题的一些答案,但它对我不起作用。 I have already a project, and now I want to integrate QR Code and barcode reader into my project. 我已经有了一个项目,现在我想将QR Code和条形码阅读器集成到我的项目中。

I downloaded the zip file from: core-2.2.zip 我从以下网址下载了zip文件: core-2.2.zip

I didn't find any "core.jar", I read that I have to integrate files added in "core" folder. 我没有找到任何“core.jar”,我读到我必须集成在“core”文件夹中添加的文件。 Do I have to add all classes to my project (the whole folder)? 我是否必须将所有类添加到我的项目(整个文件夹)? or do I have to create a jar file with that folder? 或者我是否必须使用该文件夹创建一个jar文件?

I am using Android Studio. 我正在使用Android Studio。 Any one can help me? 任何人都可以帮助我吗? thank you 谢谢

There is indeed an Android application that is part of the ZXing project. 确实有一个Android应用程序是ZXing项目的一部分。 It uses the core module released in maven central. 它使用maven central发布的核心模块。 If you have a maven project (which is unlikely for most Android applications) you can add the following dependency to your pom.xml file: 如果您有maven项目(大多数Android应用程序不太可能),您可以将以下依赖项添加到您的pom.xml文件中:

<dependency>
    <groupId>com.google.zxing</groupId>
    <artifactId>core</artifactId>
    <version>3.2.0</version>
</dependency>

for a Gradle project: 对于Gradle项目:

compile 'com.google.zxing:core:3.2.0'

or you can directly download the compiled .jar from here . 或者你可以直接从这里下载编译的.jar。

Please, notice that this answer refers to version 3.2.0 which is the latest stable one. 请注意,这个答案是指版本3.2.0,这是最新的稳定版本。 Version 2.2 could be similarly obtained. 可以类似地获得2.2版。

For QRCode reading you can also use Google Play service 7.8 and beyond. 对于QRCode阅读,您还可以使用7.8及更高版本的Google Play服务。 You may check this link from Google . 您可以从Google查看此链接

What you should do is to include a jar, you can not be downloaded. 你应该做的是包括一个罐子,你无法下载。 At first when you try to take zxing had the same problem, luckily I found the jar and I could download it. 起初当你试图采取zxing有同样的问题,幸运的是我找到了罐子,我可以下载它。 You have to verify either version which you need. 您必须验证所需的任一版本。

core 核心

I have not worked in Android Studio, this is in eclipse but I imagine it must be the same way. 我没有在Android Studio工作,这是在eclipse中,但我想它必须是相同的方式。

日食

What you need to add it is the full project zxing to your project as a library to the main project. 你需要添加它的是完整的项目,作为主项目的库,你的项目。 Activity and create a layout that include this library. 活动并创建包含此库的布局。

图书馆

Which is also the default is: 这也是默认的:

public class Validador extends CaptureActivity {

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.validador);
}

} }

Layout : 布局:

<FrameLayout
android:layout_width="wrap_content" 
android:layout_height="wrap_content"
android:layout_gravity="center">
    <include layout="@layout/capture"/>
</FrameLayout>

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

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