Android Studio Narhwal 2025.1.1中Gradle无法找到com.android.application:8.14.3插件的问题求助
Android Studio Narhwal 2025.1.1中Gradle无法找到com.android.application:8.14.3插件的问题求助
大家好,我在使用Android Studio Narhwal 2025.1.1开发Flutter项目时,构建Debug版本遭遇了Gradle插件找不到的错误,完整的构建失败日志如下:
FAILURE: Build failed with an exception. Where: Settings file 'C:\Users\Home\AndroidStudioProjects\prjname\android\settings.gradle' line: 18 What went wrong: Plugin [id: 'com.android.application', version: '8.14.3', apply: false] was not found in any of the following sources: * Gradle Core Plugins (plugin is not in 'org.gradle' namespace) * Included Builds (No included builds contain this plugin) * Plugin Repositories (could not resolve plugin artifact 'com.android.application:com.android.application.gradle.plugin:8.14.3') Searched in the following repositories: Google MavenRepo Gradle Central Plugin Repository Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. Get more help at https://help.gradle.org BUILD FAILED in 19s Error: Gradle task assembleDebug failed with exit code 1
下面是我项目中相关配置文件的内容:
settings.gradle
pluginManagement { def flutterSdkPath = { def properties = new Properties() file("local.properties").withInputStream { properties.load(it) } def flutterSdkPath = properties.getProperty("flutter.sdk") assert flutterSdkPath != null, "flutter.sdk not set in local.properties" return flutterSdkPath }() includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") repositories { google() mavenCentral() gradlePluginPortal() } } plugins { id "dev.flutter.flutter-plugin-loader" version "1.0.0" // apply true (default) or explicitly set id "com.android.application" version "8.14.3" apply false id "org.jetbrains.kotlin.android" version "2.2.0" apply false } include ":app"
app/build.gradle
plugins { id "com.android.application" id "kotlin-android" id "dev.flutter.flutter-gradle-plugin" } def keystoreProperties = new Properties() def keystorePropertiesFile = rootProject.file('key.properties') if (keystorePropertiesFile.exists()) { keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) } 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 { //compileSdkVersion flutter.compileSdkVersion //namespace "com.example.abc" compileSdkVersion 35 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.phl.abc" // 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 21 targetSdkVersion 35 versionCode 5 versionName "5" } signingConfigs { release { keyAlias keystoreProperties['keyAlias'] keyPassword keystoreProperties['keyPassword'] storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null storePassword keystoreProperties['storePassword'] } } buildTypes { release { signingConfig signingConfigs.release } } } flutter { source '../..' }
项目根目录下的android/build.gradle
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 }
另外,我执行flutter doctor --verbose的检测结果如下:
[√] Flutter (Channel stable, 3.27.1, on Microsoft Windows [Version 10.0.26100.4652], locale en-US) [770ms] • Flutter version 3.27.1 on channel stable at C:\Flutter\flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 17025dd882 (2 weeks ago), 2024-12-17 03:23:09 +0900 • Engine revision dd93de6fb1 • Dart version 3.8.1 • DevTools version 2.45.1 [√] Windows Version (11 Pro 64-bit, 24H2, 2009) [4.7s] [√] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [3.1s] • Android SDK at C:\Users\Home\AppData\Local\Android\sdk • Platform android-35, build-tools 35.0.0 • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java This is the JDK bundled with the latest Android Studio installation on this machine. To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`
我已经按照提示尝试用--stacktrace、--info等参数查看更多日志,但还是没定位到问题根源。明明settings.gradle里已经配置了google、mavenCentral和gradlePluginPortal这三个仓库,为什么还是找不到com.android.application:8.14.3插件呢?有没有大佬能帮忙分析问题所在,或者给一些排查方向?
内容来源于stack exchange




