[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

相关推荐
梦幻通灵4 小时前
Mysql字段判空实用技巧
android·数据库·mysql
龘龍龙7 小时前
Python基础(九)
android·开发语言·python
gjc5927 小时前
MySQL隐蔽 BUG:组合条件查询无故返回空集?深度排查与规避方案
android·数据库·mysql·bug
梨落秋霜8 小时前
Python入门篇【元组】
android·数据库·python
zh_xuan8 小时前
kotlin定义函数和变量
android·开发语言·kotlin
Digitally9 小时前
Android 上的联系人备份和恢复:5 种可靠且方便的方法
android
默|笙10 小时前
【Linux】进程控制(3)进程程序替换
android·linux·运维
国家二级编程爱好者10 小时前
Android Lottie使用,如何自定义LottieView?
android·前端
bst@微胖子11 小时前
CrewAI+FastAPI实现营销战略协助智能体项目
android·数据库·fastapi
子林Android11 小时前
AndroidStudio修改.android、.gradle、.AndroidStudio路径,释放C盘空间
android·android studio