AM031447 AM031447 - 1 month ago 15
Android Question

How to import ZXING to android studio?

I use android studio
I want to import 'ZXING' in my application, I find many articles and found the following site

I downloaded the ZIP and unzip, and find some tutorials
But it does not seem to be too detailed about the details, what I need to import? To achieve QRCode scan

I still have no idea how to do it

I tried Lennon URL provided
And import the 'gradle-wrapper.jar'

But when I wrote
new IntentIntegrator (this) .initiateScan ();
Still appear "Can not resolve symbol 'IntentIntegrator" message

I do have a right '.jar select Add As Library
But when an error occurs, he does not seem to be added


Finally no longer appear "Can not resolve symbol 'IntentIntegrator"
this is the code,What do I wrong?

I removed the new IntentIntegrator (this) .initiateScan (); 'applications normal operation

protected void onCreate(Bundle savedInstanceState) {
new IntentIntegrator(this).initiateScan();

my 'build.greadle'

repositories {
maven {
url ""


I had many troubles when I developed my app using zxing library. So take a look this zxing minimal:

It worked perfectly to me and was easier to implement.


Open up this file in your project:


Edit the distributionUrl line and set it too:

distributionUrl= Rebuild your project.

Update: You might want to use now.


First of all, you must remove your libs file. Then you have to remove

    maven {
        url ""

from your build.gradle of MyApplication, because that gradle is for the whole project, and it's better you use it in each module.

After that, open the build.gradle of the module app and add the following code:

repositories {

    maven {
        url ""

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile ''

    // Zxing libraries
    compile 'com.embarkmobile:zxing-android-minimal:2.0.0@aar'
    compile 'com.embarkmobile:zxing-android-integration:2.0.0@aar'
    compile ''


And finally, you need to delete from your project, otherwise, an error will show up when you compile.


To resolve the back button problem, you can do the following code:

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (resultCode == RESULT_OK) {

        String _code = data.getStringExtra("SCAN_RESULT");

        // do whatever you want