How to include Zxing library to android project?

允我心安 提交于 2019-12-04 20:58:55

问题


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.

I downloaded the zip file from: 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?

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


回答1:


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:

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

for a Gradle project:

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

or you can directly download the compiled .jar from here.

Please, notice that this answer refers to version 3.2.0 which is the latest stable one. Version 2.2 could be similarly obtained.




回答2:


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




回答3:


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.

core

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

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>


来源:https://stackoverflow.com/questions/17026904/how-to-include-zxing-library-to-android-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!