错误:
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项目从Flutterv1到Flutterv3。在代码和库更新之前,我需要重新启动这个旧项目。在iOS上它工作,但在Android上我得到这个错误。我在wrapper属性中有这个特定的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 (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,但都没有成功。
1条答案
按热度按时间euoag5mw1#
如果你只是用
flutter create -t app <app-directory>
创建一个项目,并将codebase 'lib'文件夹移动到新项目中,会怎么样?我想这是解决您问题的最好方法,因为flutter v1与v3非常不同