如何将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. I have already a project, and now I want to integrate QR Code and barcode reader into my project.

我已经在stackoverflow中读到了这个问题的一些答案,但它对我不起作用。我已经有了一个项目,现在我想将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. 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?

我没有找到任何“core.jar”,我读到我必须集成在“core”文件夹中添加的文件。我是否必须将所有类添加到我的项目(整个文件夹)?或者我是否必须使用该文件夹创建一个jar文件?

I am using Android Studio. Any one can help me? thank you

我正在使用Android Studio。任何人都可以帮助我吗?谢谢

3 个解决方案

#1


5  

There is indeed an Android application that is part of the ZXing project. It uses the core module released in 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:

确实有一个Android应用程序是ZXing项目的一部分。它使用maven central发布的核心模块。如果您有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. Version 2.2 could be similarly obtained.

请注意,这个答案是指版本3.2.0,这是最新的稳定版本。可以类似地获得2.2版。

#2


2  

For QRCode reading you can also use Google Play service 7.8 and beyond. You may check this link from Google.

对于QRCode阅读,您还可以使用7.8及更高版本的Google Play服务。您可以在Google上查看此链接。

#3


0  

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. You have to verify either version which you need.

你应该做的是包括一个罐子,你无法下载。起初当你试图采取zxing有同样的问题,幸运的是我找到了罐子,我可以下载它。您必须验证所需的任一版本。

core

I have not worked in Android Studio, this is in eclipse but I imagine it must be the same way.

我没有在Android Studio工作,这是在eclipse中,但我想它必须是相同的方式。

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.

您需要添加它的是作为主项目库的项目的完整项目。活动并创建包含此库的布局。

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>

注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.silva-art.net/blog/2013/06/10/c23ed540dbdd2607a3fb8c74d0a80ed4.html



 
© 2014-2018 ITdaan.com 粤ICP备14056181号