如何在主应用 class - Android 中使用导入的库 class

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

在我创建的应用程序中,我导入了一个名为 ZBarScanner https://github.com/dm77/ZBarScanner 的库,我想在主应用程序中单击按钮时调用它,但我无法获得参考到class,如此处所示

我们如何在 Android 中调用导入的库 class 或者我应该怎么做?

编辑。

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'
}

这是一个多项目构建,你应该在 app 文件的 build.gradle 添加另一个项目的依赖:

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

更多信息here