Search code examples
androidlibrarieszxing

Zxing library integration gradle error in android studio


The gradle file content is below

apply plugin: 'com.android.library'

ext.artifactId = 'zxing-android-embedded'

dependencies {
    compile project.zxingCore

    // Optional dependency.
    provided 'com.android.support:support-v4:22.0.0'
}


android {
    resourcePrefix 'zxing_'
    compileSdkVersion project.androidTargetSdk
    buildToolsVersion project.androidBuildTools

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src-orig', 'src']
            res.srcDirs = ['res-orig', 'res']
            assets.srcDirs = ['assets']
        }
    }

    // This is bad practice - we should fix the warnings instead.
    lintOptions {
        // Android warns about the he and id locale folders. he -> iw is already handled with a
        // symlink. TODO: what about id?
        disable 'LocaleFolder'
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
}

It gives error Could not find property 'zxingCore' on project ':zxing-android-embedded'. for the compile project.zxingCore


Solution

  • Add the following dependency to your project build.gradle

    dependencies {
        compile 'com.google.zxing:core:3.2.1'
    }
    

    In my project it works fine.