java - 错误意外令牌: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'
}
解决方案
如日志中所述,问题出在这一行,
Implementation'com.journeyapps:zxing-android-embedded:3.4.0'
将其替换为
implementation 'com.journeyapps:zxing-android-embedded:3.4.0'
更改在 implementation 关键字中,并且 implementation 关键字和依赖项的名称之间必须有一个空格。
推荐阅读
- java - 恢复数据库密码 unicentapos
- c# - 锁定 IHostedService
- kubernetes - 将用户重定向到特定 pod 的身份验证和授权
- sql - 如何使用 BigQuery 分析函数计算时间戳行之间的时间?
- javascript - 如何根据特定数字从数组中选择
- reactjs - 当用户按下视图中的按钮时,更改 TabBarNavigator 中的活动选项卡
- sql-server - 如何从经典 ASP 中读取 SQL 始终加密的列
- c# - 如何使用符号和源代码打包和部署 NuGet 包,以便调试器可以使用该源代码?
- excel - Excel - 索引匹配公式
- amazon-web-services - AWS -a 配置触发器以仅检测目录创建而不检测文件创建