首页 > 解决方案 > 错误意外令牌:com.journeyapps:zxing-android-embedded:3.4.0 @ line 40, column 21. in build.gradle

问题描述

我正在按照教程在 android studio 中构建基于 android 的 QR 码扫描仪。但是,当我尝试在 build.gradle(app) 文件中实现 Zxing 时,出现错误显示:

意外令牌:com.journeyapps:zxing-android-embedded:3.4.0 @ 第 40 行,第 21 列。实现'com.journeyapps:zxing-android-embedded:3.4.0'

这是 gradle.build 文件中的代码:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "com.example.myapplication"
        minSdkVersion 15
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'



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

        //add this dependency
      Implementation'com.journeyapps:zxing-android-embedded:3.4.0'

    }

标签: javaandroidandroid-studiozxing

解决方案


如日志中所述,问题出在这一行,

Implementation'com.journeyapps:zxing-android-embedded:3.4.0'

将其替换为

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

更改在 implementation 关键字中,并且 implementation 关键字和依赖项的名称之间必须有一个空格。


推荐阅读