[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

相关推荐
传奇开心果编程14 分钟前
【Flutter踩坑排雷】第25课:ScrollController 误用坑|跳转失效、监听泄漏与“控制器未附加”
android·flutter·ios·移动开发·跨平台·dart·声明式ui
慕容雪_4 小时前
Capacitor8-Android打包完整手册
android·打包·capacitor
阿杰m7 小时前
Android源码第十三章:Bluetooth——沿一次发现走到控制器
android
booboosui8 小时前
派活给另一个 AI:前后两次文件夹快照,就是交付清单
android
普通人613 小时前
MySQL_FIND_IN_SET函数详解
android·数据库·mysql
拼图20914 小时前
VSCode 正则表达式使用指南
ide·vscode·正则表达式
好的佩奇1 天前
Dart 之集合元素
android·flutter·dart
Easyhood1 天前
Android 开发入门实践(十四):Compose 副作用入门与四个常用 API
android·开发语言·kotlin·android jetpack·compose
FlightYe1 天前
音视频修炼之容器与协议(四):RTSP详解
android·linux·ffmpeg·音视频·dash
疯华整猫1 天前
删掉 LeakCanary 那天,我用 Trae 自己撸了一套:最难的不是分析堆,是决定什么时候 dump
android·人工智能·性能优化