背景:我正在使用安卓工作室,并试图将应用程序更新为最新的API(34),并发布到谷歌play商店。
ERROR:
* Where:
Build file '...android\app\build.gradle' line: 3
* What went wrong:
Plugin [id: 'com.android.application', version: '8.5.0', 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.5.0')
Searched in the following repositories:
Gradle Central Plugin Repository
app/build.gradle:
plugins {
//noinspection AndroidGradlePluginVersion
id 'com.android.application' version '8.5.0' apply false
id 'org.jetbrains.kotlin.android' version '1.9.22' apply false
id 'dev.flutter.flutter-gradle-plugin' apply false
id 'com.google.gms.google-services' version '4.4.2' apply false
}
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'
}
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
namespace 'com.example.application'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
applicationId "appID"
minSdkVersion 21
compileSdk 34
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
ndk {
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86_64'
}
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
ndkVersion '25.1.8937393'
compileSdk 34
}
flutter {
source '../..'
}
}
我的安卓系统/build.gradle:
allprojects {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
rootProject.layout.buildDirectory = '../build'
subprojects {
project.layout.buildDirectory = "${rootProject.layout.buildDirectory}/${project.name}"
project.evaluationDependsOn(":app")
}
subprojects {
project.evaluationDependsOn(':app')
}
tasks.register("clean", Delete) {
delete rootProject.layout.buildDirectory
}
subprojects {
afterEvaluate { project ->
if (project.hasProperty('android')) {
project.android {
if (namespace == null) {
namespace project.group
}
}
}
}
}
我的渐变设置:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
rootProject.name = "My Application"
include ':app'
project(':app').projectDir = new File(rootDir, 'company/android/app/')
android/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 'com.android.application' version '8.5.0'
id 'org.jetbrains.kotlin.android' version ''1.9.22'
id 'dev.flutter.flutter-gradle-plugin'
id "dev.flutter.flutter-plugin-loader"
id 'com.google.gms.google-services' version '4.4.2'
}
include ":app"
gradle包装器属性:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
我试图检查所有版本的兼容性,但总是遇到同样的错误。