错误:
Exception: [!] Your app is using an unsupported Gradle project. To fix this problem, create a new project by running `flutter create -t app <app-directory>` and then move the dart code, assets and pubspec.yaml to the new project.
你好!我必须将 flutter 项目从 flutter v1 更新到 flutter v3。在代码和库更新之前,我需要重新启动这个旧项目。在 ios 上它可以工作,但在 android 上我收到此错误。我在包装属性中有这个特定的 gradle 版本:
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
;
然后这是我的build.gradle(在android文件夹下):
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.8'
}
}
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
}
然后看起来很奇怪,src 文件夹下没有 build.gradle 文件,应该在其中定义 minSdkVersion、targetSdkVersion、插件等。 这是我的 flutter doctor 输出:
[✓] Flutter (Channel beta, 1.24.0-10.2.pre, on macOS 13.3 22E252 darwin-arm, locale it-IT)
• Flutter version 1.24.0-10.2.pre at /Users/alessandro_cancelliere/fvm/versions/1.24.0-10.2.pre
• Framework revision 022b333a08 (2 years, 7 months ago), 2020-11-18 11:35:09 -0800
• Engine revision 07c1eed46b
• Dart version 2.12.0 (build 2.12.0-29.10.beta)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/alessandro_cancelliere/Library/Android/sdk
• Platform android-34, build-tools 34.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 14.3)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 14.3, Build version 14E222b
• CocoaPods version 1.12.1
[✓] Android Studio (version 2022.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
[✓] IntelliJ IDEA Ultimate Edition (version 2021.1)
• IntelliJ at /Applications/IntelliJ IDEA.app
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
[✓] VS Code (version 1.79.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.67.20230601
我已经尝试了很多解决方案,正如这篇文章所建议的https://stackoverflow.com/questions/62064188/exception-your-app-is-using-an-unsupported-gradle-project我也尝试了不同的版本Java,但没有任何效果。
如果您只是使用
flutter create -t app <app-directory>
创建一个项目并将代码库“lib”文件夹移动到新项目,该怎么办?我认为这是解决您问题的最佳方法,因为 flutter v1 与 v3 有很大不同
你找到解决办法了吗?除了创建一个新项目?