【发布时间】:2022-08-09 05:33:13
【问题描述】:
运行 flutter build appbundle 命令时会显示此错误:
-
在哪里: 构建文件 \'C:\\Projetos\\Vai para o GitHub\\devstravel\\android\\app\\build.gradle\' 行:38
- 出了什么问题: 评估项目 \':app\' 时出现问题。
没有方法签名:build_3p7kb4yalue4j0dkob18nu1yo.android() 适用于参数类型:(build_3p7kb4yalue4j0dkob18nu1yo$_run_closure2) 值:[build_3p7kb4yalu4j0dkob18nu1yo$_run_closure2@2d50add8]
- 尝试:
使用 --stacktrace 选项运行以获取堆栈跟踪。 使用 --info 或 --debug 选项运行以获得更多日志输出。 运行 --scan 以获得完整的见解。
- 在https://help.gradle.org获得更多帮助
I don\'t understand why this is wrong, I\'m uploading my 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.\")
}
def flutterVersionCode = localProperties.getProperty(\'flutter.versionCode\')
if (flutterVersionCode == null) {
flutterVersionCode = \'1\'
}
def flutterVersionName = localProperties.getProperty(\'flutter.versionName\')
if (flutterVersionName == null) {
flutterVersionName = \'1.0\'
}
apply plugin: \'com.android.application\'
apply plugin: \'kotlin-android\'
apply from: \"$flutterRoot/packages/flutter_tools/gradle/flutter.gradle\"
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file(\'key.properties\')
if (keystorePropertiesFile.exists()){
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
compileSdkVersion flutter.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = \'1.8\'
}
sourceSets {
main.java.srcDirs += \'src/main/kotlin\'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId \"com.junior.devstravel\"
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
signingConfigs{
release{
keyAlias keystoreProperties[\'keyAlias\']
keyPassword keystoreProperties [\'keyPassword\']
storeFile keystoreProperties [\'storeFile\'] ? file(keystoreProperties[\'storeFile\']) : null
sotePassword keystoreProperties [\'storePassword\']
}
}
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.release
}
}
}
flutter {
source \'../..\'
}
dependencies {
implementation \"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version\"
}
-
通常,如果您的应用程序在此错误之前运行良好,请检查您必须进行哪些新更改并逐行注释新更改并测试它是否构建。希望这应该有效,但发布完整的 build.gradle 文件,包括指向文件错误开始位置的指针。
-
我也有同样的问题。我通过禁用proguard来解决它。请参阅以下文档。 github.com/flutter/flutter/issues/92974
标签: flutter