对于[this flutter库] [1],barcode scanner
应该添加firebase
到项目中,但是这样做之后,我得到了这个错误,我还不能解决这个问题
以调试模式在WAS LX1A上启动lib \ main.dart ...正在初始化 gradle ...解决依赖关系... *运行Gradle时出错:ProcessException:退出了进程“ E:\ Projects \ Flutter \ barcode_scanner \ android \ gradlew.bat” 异常:
失败:构建失败,并出现异常。
其中:构建文件'E:\ Projects \ Flutter \ barcode_scanner \ android \ app \ build.gradle'行: 14
出了什么问题:评估项目':app'时出现问题。
ASCII
尝试:使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行以获取更多日志输出。使用--scan运行以获取完整的见解。
- 获得更多帮助
在6秒内建立失败命令: E:\ Projects \ Flutter \ barcode_scanner \ android \ gradlew.bat app:properties
完成错误:请在以下位置查看您的Gradle项目设置: android /文件夹。
第14行是:
apply plugin: 'com.android.application'
我不确定是什么问题,这是我对此的实现方式
pabspec.yaml
内容:
version: 1.0.0+1
environment:
sdk: '>=2.0.0-dev.28.0 <3.0.0'
dependencies:
flutter:
sdk: flutter
firebase_core: ^0.4.0
...
...
android/build.gradle
内容:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.3.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
android/app/build.gradle
内容:
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 28
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "barcodescanner.pishguy.barcode_scanner"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
testImplementation 'junit:junit:4.12'
implementation 'com.google.firebase:firebase-core:17.0.1'
androidTestImplementation 'androidx.test:runner:1.3.0-alpha01'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0-alpha01'
}
apply plugin: 'com.google.gms.google-services'
运行flutter
命令:
E:\Projects\Flutter\barcode_scanner>flutter pub get
Running "flutter pub get" in barcode_scanner... 2.7s
[1]: https://github.com/facundomedica/fast_qr_reader_view
答案 0 :(得分:4)
嗨,大家好,这是我的确切问题;我设法最终解决了这个问题;
这是我对代码进行的更改;
在AppName / Android / gradle / build.gradle上:
buildscript {
ext.kotlin_version = '1.3.50' //had to changed it previously 1.2.71
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.1' //had to changed previously 3.2.1
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.2'
}
}
然后在AppName / Android / gradle / wrapper / gradle-wrapper.properties上,我刚刚更改了这一行:
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip //it was peviously gradle-4.10.2-all.zip
所有这些更改之后,我的应用程序开始工作!
答案 1 :(得分:1)
如果该'com.google.gms:google-services:4.3.0'。 将其切换为“ com.google.gms:google-services:4.2.0” 不起作用或带来其他错误,如我的那样。......添加此
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "27.1.1"
}
if (details.requested.group == 'androidx.core'
&& !details.requested.name.contains('androidx') ) {
details.useVersion "1.0.1"
}
}
}
}
到android / build.gradle
因此您的代码将是
buildscript {
ext.kotlin_version = '1.2.51'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.2.0'
}
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "27.1.1"
}
if (details.requested.group == 'androidx.core'
&& !details.requested.name.contains('androidx') ) {
details.useVersion "1.0.1"
}
}
}
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
答案 2 :(得分:0)
'com.google.gms:google-services:4.3.0'有问题。
将其切换为'com.google.gms:google-services:4.2.0',对我来说就可以使用。
答案 3 :(得分:0)
最新版本的firebase库中有一些breaking changes。我遇到了同样的问题,但是在migrating to AndriodX之后一切正常。