在为我的Futter应用程序构建发布apk时,我遇到了这个问题,我已经try 更改到几乎所有版本的Kotlin.有人能帮我解决这个问题吗? (https://i.stack.imgur.com/fDrwj.png)

我试着换成几乎所有版本的柯特林,

这是我的安卓/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.")
}

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: 'com.google.gms.google-services'
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
    ndkVersion flutter.ndkVersion

    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.rewaytech.rewayusers"
        // You can update the following values to match your application needs.
        // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
        minSdkVersion 21
        targetSdkVersion 33
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

   signingConfigs {
       release {
           keyAlias keystoreProperties['keyAlias']
           keyPassword keystoreProperties['keyPassword']
           storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
           storePassword keystoreProperties['storePassword']
       }
   }
   buildTypes {
       release {
           signingConfig signingConfigs.release
       }
   }

}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation platform('com.google.firebase:firebase-bom:31.2.3')
    implementation 'com.google.firebase:firebase-analytics-ktx'
}

这是我的安卓/build.gradle

buildscript {
    ext.kotlin_version = '1.8.0'
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.2.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.15'
    }
}


allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

tasks.register("clean", Delete) {
    delete rootProject.buildDir
}

推荐答案

This is a great answer.

他直截了当地详细解释了引擎盖下发生了什么!

如果这不起作用,请让我知道,我会为你提供更多的支持,快乐编码!

Flutter相关问答推荐

如何将图像从顶部和底部半向外设置为飘动

在Riverpod ConsumerWidget中使用文本编辑控制器

文本未设置在集装箱摆动的中心

悬停时打开Flutter 下拉按钮

GetConnect Post API调用在Flutter Web中不起作用说:415不支持的媒体类型

Flutter :执行com.android.build.gradle.internal.tasks.MergeNativeLibsTask$MergeNativeLibsTaskWorkAction时出现故障

Flutter 渲染HTML和数学(LaTeX和Katex)

未处理的异常:第1行第5列出现错误:无效的媒体类型:应为/&;.从API获取数据时在Flutter中

请求已在 flutter 中发送到 django 服务器,并且已返回响应,但条件仍然为 false

Flutter:如何在 Future 函数上添加网络判断和 showDialog

自定义绘画未显示 - Flutter

Flutter中如何实现带有变化图标的浮动操作按钮?

PreferredSizeWidget类不能用作混合,因为它既不是混合类也不是混合

如何在两个不同的路由(屏幕)之间正确设置 BlocProvider?

Flutter中如何连续获取TextField的文本是否为空?

String类型不是Widget类型的子类型?在dart 中

如何修复int类型不是String类型的子类型

Flutter Web App 未启动:脚本的 MIME 类型不受支持

一个或多个插件需要更高的 Android SDK 版本

使用 hydrad_bloc 的预览包