Search code examples
androidreferencebarcode-scannerzbar

How to use imported lib class in main app class - Android


In the app i have created i imported a Lib called ZBarScanner https://github.com/dm77/ZBarScanner which i would like to call upon clicking button in the main app but i cant get reference to the class which am calling as indicated here Error preview image

How do we call imported Lib class in Android or what should i do?

EDIT.

Build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.mobiledatabook.com.qrdecoder"
        minSdkVersion 10
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.0.1'
    compile 'com.android.support:design:25.0.1'
    testCompile 'junit:junit:4.12'
}

Solution

  • It's a Multi-project build, you should add the dependency of the other project in the build.gradle of the app file:

    dependencies {
        compile project(':zBarScannerLibrary')
        ...
    }
    

    More info here.