在以下任何来源中均未找到插件 [id: 'com.android.application', 版本: '8.5.0']

问题描述 投票:0回答:1

上下文:我正在使用 android studio 并尝试将应用程序更新到最新的 API (34) 并发布到 Google 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

应用程序/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 '../..'
}

}

我的android/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
                                }
            }
        }
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
   }
}

我的gradle设置:

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

我尝试检查所有版本兼容性,但仍然面临相同的错误。

android flutter gradle android-gradle-plugin gradle-plugin
1个回答
0
投票

有两件事:

  • Gradle
    settings.gradle
    文件需要位于项目的根文件夹中。子项目文件夹中的此类文件没有任何效果,所以我不确定为什么您最终会在
    android
    文件夹中出现这样的文件。
  • Android 插件未存储在 Gradle 插件门户中(错误消息显示这是 Gradle 寻找插件的唯一位置),因此您需要告诉 Gradle 也可以通过将以下内容添加到您的 ( root)
    settings.gradle
    文件:
pluginManagement {
    repositories {
        google()
        gradlePluginPortal()
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.