2

I've started a new project in Android Studio and I want to import the zxing-android-embedded to allow to me create a simple barcode scanner within my application. Found here on github

Following instruction on there and also on different sources like this SO answer: https://stackoverflow.com/a/23788163/3364482

However I have added the compile optins to my build.gradle but I'm getting the "Failed to resolve" errors:

Failed to resolve: com.google.zxing:core:3.2.0
Failed to resolve: com.journeyapps:zxing-android-embedded:2.3.0
Failed to resolve: com.journeyapps:zxing-android-integration:2.3.0

But as far as I'm aware my buid.gradle is as instructed:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

defaultConfig {
    applicationId "com.myapps.practice.helloworld"
    minSdkVersion 19
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}
repositories {
    jcenter()
}
dependencies {
    compile 'com.journeyapps:zxing-android-embedded:2.3.0@aar'
    compile 'com.journeyapps:zxing-android-integration:2.3.0@aar'
    compile 'com.google.zxing:core:3.2.0'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
}

EDIT: I'm not in Offline Mode.

Community
  • 1
  • 1
MikeS
  • 237
  • 1
  • 5
  • 22
  • Did you appear to be in Offline Mode? – nuuneoi Apr 05 '16 at 13:48
  • No, Offline Mode is not ticked. I'm behind a proxy but Check Connection returns successful (In settings). – MikeS Apr 05 '16 at 13:56
  • I made a commit to this project that works fine, and here is the Gradle file. https://github.com/xuxingliu922/DeviceSDK/blob/master/SmartDeviceSDK/build.gradle – OneCricketeer Apr 05 '16 at 14:10
  • Thanks for that, I notice my BuildTools isn't 'x.x.2' like yours is or the one on the github's project page. Going to upgrade now and see if that works. – MikeS Apr 05 '16 at 14:34
  • Upgraded buildToolsVersion "23.0.3" but still no avail :( – MikeS Apr 05 '16 at 15:19

7 Answers7

2

Try this, this is the most recent version from git:

dependencies {
    compile 'com.journeyapps:zxing-android-embedded:3.2.0@aar'
    compile 'com.google.zxing:core:3.2.1'
    compile 'com.android.support:appcompat-v7:23.1.0'   // Version 23+ is required
}

android {
    buildToolsVersion '23.0.2' // Older versions may give compile errors
}
Tom Sabel
  • 3,935
  • 33
  • 45
0

There is my gradle file:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "space.klapeyron.testqr"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'

    //added by Klapeyron start
    compile 'com.journeyapps:zxing-android-embedded:3.2.0@aar'
    compile 'com.google.zxing:core:3.2.1'
    compile 'com.android.support:appcompat-v7:23.1.0'   // Version 23+ is required
    //added by Klapeyron end
}

//added by Klapeyron start
repositories {
    jcenter()
}
//added by Klapeyron end
klapeyron
  • 502
  • 7
  • 18
0

In my case, I had to Upgrade my gradle to 3.4 and use implementation instead of compile:

dependencies {
   implementation 'com.journeyapps:zxing-android-embedded:3.0.2@aar'
   implementation 'com.google.zxing:core:3.2.0'
   //...
}

You might also need to clear the cache and restart if it still doesn't work.

Gomez NL
  • 912
  • 9
  • 12
0

In build.gradle (:app) add: implementation 'com.journeyapps:zxing-android-embedded:4.0.0' implementation 'com.google.zxing:core:3.4.0' It works for me. Maybe it'll help somebody who get this error in 2019 :)

savera sleemy
  • 73
  • 1
  • 12
0

This is how I have imported it :

implementation 'com.journeyapps:zxing-android-embedded:3.2.0@aar'
implementation 'com.google.zxing:core:3.2.1'
0

The latest version for 24+ is

implementation 'com.journeyapps:zxing-android-embedded:4.2.0'
0

for the latest version i replaced

implementation "com.journeyapps:zxing-android-3.4.0"

with:

implementation 'com.journeyapps:zxing-android-embedded:3.5.0'

and it worked for me