[Android Studio] Failed to apply plugin [id ‘com.android.application‘]

参考:

Solve Gradle error: Plugin with id 'com.android.application' not found | sebhastian

步骤:

1.检查settings.gradle里的 maven 仓库是否存在,正常内容如下

pluginManagement {

repositories {

google()

mavenCentral()

gradlePluginPortal()

}

}

dependencyResolutionManagement {

repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)

repositories {

google()

mavenCentral()

}

}

rootProject.name = "TestMediaPlayer"

include ':app'

2.检查 build.gradle 里面的 gradle 信息是否存在,这里有问题可能行较大,有时候会是空的,应该有如下内容:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

plugins {

id 'com.android.application' version '7.3.1' apply false

id 'com.android.library' version '7.3.1' apply false

id 'org.jetbrains.kotlin.android' version '1.7.21' apply false

}

task clean(type: Delete) {

delete rootProject.buildDir

}

3.检查gradle-wrapper.properties里的gradle版本和build.gradle版本是否匹配,每个工程都有一个gradle-wrapper.properties文件,内容如下:

#Thu Feb 01 15:08:44 CST 2024

distributionBase=GRADLE_USER_HOME

distributionPath=wrapper/dists

distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip

zipStoreBase=GRADLE_USER_HOME

zipStorePath=wrapper/dists

相关推荐
MoSTChillax28 分钟前
数字人竞品分析(中):核心功能、产品使用与技术能力对比
ide·macos·xcode
极客猴子3 小时前
Android录音转写频繁卡顿?多款APP长时间会议场景稳定性实测
android·人工智能·智能手机·飞书
Kapaseker3 小时前
Boolean 变量到底该怎么命名?
android·kotlin
AFinalStone3 小时前
Android 7系统异常问题排查(六)应用异常(上)—ANR机制全解
android·系统异常
雾屿_Mistisle3 小时前
文件包含漏洞(File Inclusion)
android
林三的日常3 小时前
AI编程IDE卡成PPT?低配电脑的末日来了
ide·电脑·ai编程
小孔龙4 小时前
Android 图形系统全景
android·计算机图形学
2501_915921434 小时前
详细解析,iOS 应用上架 App Store 的完整流程与指南
android·ios·小程序·https·uni-app·iphone·webview
qq_425516184 小时前
录音转文字工具免费下载:免费额度与功能限制对比
android·人工智能·智能手机·powerpoint
2501_915106324 小时前
SwiftUI项目创建详解:使用Xcode从零开始创建第一个App项目
ide·vscode·ios·swiftui·个人开发·xcode·敏捷流程