【发布时间】:2021-03-09 13:13:36
【问题描述】:
实际上,当我尝试为 Android 运行 Flutter 构建时,我遇到了一个非常奇怪的错误。
首先,我想向您展示错误。之后,我将向您展示我的项目的 Flutter doctor 结果和特定代码部分。
使用flutter run运行android项目后出错
- 出了什么问题:评估项目 ':app' 时出现问题。
在 DefaultConfig_Decorated{name=main, dimension=null, 上找不到参数 [1.0.0, null] 的方法 versionName() minSdkVersion=DefaultApiVersion{mApiLevel=18, mCodename='null'}, targetSdkVersion=DefaultApiVersion{mApiLevel=28, mCodename='null'}, renderscriptTargetApi=null,renderscriptSupportModeEnabled=null, renderscriptSupportModeBlasEnabled=null, renderscriptNdkModeEnabled=null,versionCode=8,versionName=null, applicationId=de.danielederosa.virtualguestbook, testApplicationId=null,testInstrumentationRunner=null, testInstrumentationRunnerArguments={},testHandleProfiling=null, testFunctionalTest=null,signingConfig=null,resConfig=null, mBuildConfigFields={},mResValues={},mProguardFiles=[], mConsumerProguardFiles=[], mManifestPlaceholders={}, mWearAppUnbundled=null} 类型 com.android.build.gradle.internal.dsl.DefaultConfig.
尝试:使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。运行 --scan 以获得完整的见解。
通过https://help.gradle.org获得更多帮助
在 6 秒内构建失败异常:Gradle 任务 assembleDebug 失败 退出代码 1 退出 (sigterm)
build.gradle
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.2'
classpath 'com.google.gms:google-services:4.3.4'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
gradle.wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
pubspec.yaml
version: 1.0.0+8
有趣的是它显示versionName=null,如果我这样覆盖变量:
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "de.danielederosa.virtualguestbook"
minSdkVersion 18
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName '1.0.0',
multiDexEnabled true
}
您知道可能是什么问题吗?也许与 gradle 版本有些不兼容?
【问题讨论】: