提问人:Vignesh G 提问时间:10/29/2023 更新时间:10/29/2023 访问量:62
Flutter 构建失败:找不到 'com.android.application' 插件
Flutter Build Failure: Unable to Find 'com.android.application' Plugin
问:
我刚刚开始通过在线关注一些资源来学习 flutter,我什至还没有创建一个项目,但我已经遇到了问题。
我在尝试使用 Visual Studio Code 在 Android 设备上运行我的 Flutter 应用程序时遇到了构建失败问题。该错误指向有关“com.android.application”的插件识别问题。以下是错误消息的片段: 失败:生成失败,出现异常。
哪里: 构建文件“D:\newapp\newtest\android\app\build.gradle”行:2
出了什么问题: 插件 [id: 'com.android.application'] 在以下任何来源中均未找到:
- Gradle Core 插件(插件不在“org.gradle”命名空间中)
- 包含的构建(包含的构建均不包含此插件)
- 插件存储库(插件依赖项必须包含此源的版本号)
- 尝试:
使用 --stacktrace 选项运行以获取堆栈跟踪。 使用 --info 或 --debug 选项运行以获取更多日志输出。 使用 --scan 运行以获取完整的见解。
- 在 https://help.gradle.org 获取更多帮助
构建在 25 秒内失败
android/build.gradle 中的代码:
buildscript {
ext.kotlin_version = '1.7.10'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.3.0'
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')
}
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
android/app/build.gradle 中的代码:
plugins {
id "com.android.application"
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
}
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
android {
namespace "com.example.newtest"
compileSdkVersion flutter.compileSdkVersion
ndkVersion flutter.ndkVersion
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 "com.example.newtest"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
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 {}
我试图创建一个新项目来查看问题是否仍然存在,不幸的是,它确实存在。我还确保正确安装了 Android SDK,并设置了ANDROID_HOME环境变量。我已经清理了项目并分别使用 flutter clean 和 flutter pub get 再次获取了依赖项,但错误仍然存在。
我尝试更新依赖项,但无法更新它们,调试控制台一直告诉我恢复到我所做的更改,所以我放弃了,或者不知道如何更新依赖项,如果您知道如何更新它们,也请告诉我。
有没有人遇到过类似的问题或对如何解决这个问题有任何建议?任何帮助将不胜感激!
谢谢!
答: 暂无答案
评论