如何在不安装外部Zxing应用程序的情况下将Android Studio中的Zxing集成到android项目中

时间:2016-01-28 17:58:52

标签: android android-studio zxing

我试图创建一个应该能够扫描条形码的应用程序。它应该无需安装外部Zxing应用程序。我已经找到了答案,发现了这个:

here

答案是指Eclipse,但如果尝试在Android Studio中执行相同操作,我也不知道从哪里开始。

1 个答案:

答案 0 :(得分:1)

尝试将此添加到build.gradle文件

dependencies {

    // other dependencies

    // ZXing
    // Supports Android 4.0.3 and later (API level 15)
    compile 'com.journeyapps:zxing-android-embedded:2.0.1@aar'

    // Convenience library to launch the scanning and encoding Activities.
    // It automatically picks the best scanning library from the above two, depending on the
    // Android version and what is available.
    compile 'com.journeyapps:zxing-android-integration:2.0.1@aar'

    // Version 3.0.x of zxing core contains some code that is not compatible on Android 2.2 and earlier.
    // This mostly affects encoding, but you should test if you plan to support these versions.
    // Older versions e.g. 2.2 may also work if you need support for older Android versions.
    compile 'com.google.zxing:core:3.2.1'

}