【发布时间】:2022-09-25 00:39:03
【问题描述】:
我正在尝试在 macOS 上的 android 模拟器中打开我的应用程序,但出现以下错误
* Where:
Build file \'/Users/home/app_sources/my_app/android/app/build.gradle\' line: 63
* What went wrong:
A problem occurred evaluating project \':app\'.
> Could not find method flutter() for arguments [build_enl1wb3rxbgojqnsmrkb1pqib$_run_closure3@4a124cf3] on project \':app\' of type org.gradle.api.Project.
另外,如果我尝试Open Android module in Android Studio
打开时没有配置
当我尝试添加配置时,没有可供选择的模块
我过去 3 天一直面临这个问题,相信我,我已经尝试了这个网站上的每个主题,关于这个问题的每一篇文章都没有任何效果,所以请不要建议谷歌搜索,因为我已经这样做了很多!
笔记:
- 使用
Sync Project with Gradle Files返回与上述相同的错误 - 使用
Invalidate Caches也无济于事。 - 在
settings.gradle中评论include \':app\'并同步,再次取消评论和同步也无济于事。任何想法?
更新
settings.gradleinclude \':app\' def localPropertiesFile = new File(rootProject.projectDir, \"local.properties\") def properties = new Properties() assert localPropertiesFile.exists() localPropertiesFile.withReader(\"UTF-8\") { reader -> properties.load(reader) } def flutterSdkPath = properties.getProperty(\"flutter.sdk\") assert flutterSdkPath != null, \"flutter.sdk not set in local.properties\" apply from: \"$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle\"android/build.gradlebuildscript { ext.kotlin_version = \'1.6.10\' repositories { google() mavenCentral() } dependencies { classpath \'com.android.tools.build:gradle:4.1.3\' classpath \"org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version\" } } allprojects { repositories { google() mavenCentral() } } rootProject.buildDir = \'../build\' subprojects { project.buildDir = \"${rootProject.buildDir}/${project.name}\" } subprojects { project.evaluationDependsOn(\':app\') } task clean(type: Delete) { delete rootProject.buildDir }android/app/build.gradledef 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: \'kotlin-android\' apply from: \"$flutterRoot/packages/flutter_tools/gradle/flutter.gradle\" android { compileSdkVersion flutter.compileSdkVersion 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 \"xxx.xxx.xxx.xxx\" minSdkVersion 19 targetSdkVersion 32 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 } } } flutter { source \'../..\' } dependencies { implementation \"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version\" }
-
嘿,你能分享你的
setting.gradle和build.gradle应用程序级别和项目级别的文件吗? -
@Ashutoshsingh 已更新
-
在这个项目中添加了火力基地?
-
@Ashutoshsingh 没有
标签: android flutter macos dart