[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

相关推荐
花开月满西楼39 分钟前
保姆级【快数学会Android端“动画“】+ 实现补间动画和逐帧动画!!!
android·前端·android studio
这儿有一堆花42 分钟前
打造你的 Android 图像编辑器:深入解析 PhotoEditor 开源库
android·开源
皮皮高2 小时前
itvbox绿豆影视tvbox手机版影视APP源码分享搭建教程
android·前端·后端·开源·tv
EnzoRay2 小时前
MotionEvent
android
玲小珑3 小时前
Auto.js 入门指南(七)定时任务调度
android·前端
大河qu3 小时前
IoT/HCIP实验-3/LiteOS操作系统内核实验(任务、内存、信号量、CMSIS..)
ide·物联网·liteos·liteos studio·cmsis接口
墨狂之逸才3 小时前
adb常用命令调试
android
YoungForYou3 小时前
Android端部署NCNN
android
移动开发者1号3 小时前
Jetpack Compose瀑布流实现方案
android·kotlin
移动开发者1号3 小时前
Android LinearLayout、FrameLayout、RelativeLayout、ConstraintLayout大混战
android·kotlin