flutter项目报错:Could not find method flutter() for arguments
程序员文章站
2022-07-06 13:45:42
flutter项目报错:Could not find method flutter() for arguments直接进入正题:第一次使用AS创建flutter项目,运行在夜神模拟器里,但是今天不知道碰到了啥,就报错了报错内容:我们对Markdown编辑器进行了一些功能拓展与语法支持,除了标准的Markdown编辑器功能,我们增加了如下几点新功能,帮助你用它写博客:全新的界面设计 ,将会带来全新的写作体验;在创作中心设置你喜爱的代码高亮样式,Markdown 将代码片显示选择的高亮样式 进...
已解决!: flutter项目报错:Could not find method flutter() for arguments
直接进入正题:
第一次使用AS创建flutter项目,运行在夜神模拟器里,但是今天不知道碰到了啥,就报错了
报错内容:
就是这个错误,找不到任何原因!
相关代码:
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 from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
flutter {
source '../..'
}
android {
compileSdkVersion 28
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.flutter_app2"
minSdkVersion 16
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
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.debug
}
}
}
adroid/build.gradle
buildscript {
repositories {
// google()
// jcenter()
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/jcenter' }
maven { url 'http://maven.aliyun.com/nexus/content/groups/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
}
}
allprojects {
repositories {
// google()
// jcenter()
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/jcenter' }
maven { url 'http://maven.aliyun.com/nexus/content/groups/public' }
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
参考了一下俩个博客,解释的原因和我一样,但是解决方法就不会啦
https://*.com/questions/57948118/could-not-find-method-flutter-for-arguments-in-visual-studio-code
https://*.com/questions/57947444/error-on-build-gradle-in-visual-studio-codeflutter
我把他们的回答粘出来
解决了,重新安装flutter sdk就行啦,真菜,就是本地的那个,我也不知道咋回事,重新装一遍再打开就可以用啦。唉,真鸡儿菜!
参考博客(里面有flutter sdk 的安装过程):
https://www.cnblogs.com/yangyxd/p/8809512.html
本文地址:https://blog.csdn.net/lichaoqu/article/details/107422548
上一篇: 鸡蛋羹一般蒸几分钟
下一篇: 计算机组成原理之指令(三)