我试图在我的 flutter 应用程序中放置广告,事实证明这对我来说比创建应用程序本身更复杂(我是一个从 flutter 开始的新手开发者)。
当我尝试启动我的应用程序时,出现错误,内容如下: [!] 您的项目需要更新版本的 Kotlin Gradle 插件。在https://kotlinlang.org/docs/gradle.html#plugin-and-versions上找到最新版本,然后更新 C:\Users\User\Desktop\Dev\adtest\android\build.gradle: ext.kotlin_version = '' 异常:Gradle 任务 assembleDebug 失败,退出代码为 1
问题看起来很简单,我必须更新控制台建议的字段。令我惊讶的是,android/build.gradle 上的 build.grade 文件中不存在 ext.kotlin_version = " " 字段。也不存在应包含它的 buildscript { } apatagate。我安装了 android Studio,更新了 Flutter,我使用 Visual Studio 代码,一切显然都是正确的,除了这一点。
感谢您的帮助。
小智 18
在文件中添加ext.kotlin_versionkotlin 依赖项<app>/android/build.gradle。
buildscript {
ext.kotlin_version = '1.5.0' //use latest
...
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
...
}
Run Code Online (Sandbox Code Playgroud)
小智 7
获取最新版本的官方网站链接 可以查看 <project_name>/android/build.gradle
buildscript {
ext.kotlin_version = '1.6.21'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
Run Code Online (Sandbox Code Playgroud)
}
这是一个老问题,但仍然有效。我几乎花了一整天的时间来排除故障并使用各种组合。"myapp_root_folder\android\settings.gradle"最终我在文件中做了这个更改
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.3.0" apply false
//id "org.jetbrains.kotlin.android" version "1.7.10" apply false **//Replaced this**
id "org.jetbrains.kotlin.android" version "1.9.22" apply false **// With This**
}
Run Code Online (Sandbox Code Playgroud)
希望它能帮助某人。
小智 0
我遇到了同样的错误并通过这种方法解决了它。我希望这也适合你。只需按照以下步骤操作即可
| 归档时间: |
|
| 查看次数: |
76495 次 |
| 最近记录: |