[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

相关推荐
恋猫de小郭3 分钟前
Flutter 状态管理基准测评,一个很有趣的观点
android·前端·flutter
可乐鸡翅yeah_5 分钟前
App WebView 加载 M3U8 流媒体踩坑,安卓 iOS 混合开发播放异常定位
android·ios·harmonyos·m3u8·m3u8在线播放
木卫四科技30 分钟前
从函数劫持到智能体控制平面:Hook 如何从 Linux-Android 演化到 Agent Runtime
android·linux·人工智能·安全
菠萝加点糖32 分钟前
Android applicationIdSuffix 详解
android·gitee·kotlin
AIGC小尼44 分钟前
穿山甲 + 腾讯短剧短视频聚合广告平台|Android+SpringBoot+Vue+Docker 完整部署指南
android·vue.js·spring boot·聚合广告·广告平台·穿山甲广告·腾讯广告
JMchen1233 小时前
【Android 性能优化实战 60 讲】06 GPU 呈现模式与卡顿视觉验证:拆解柱状图分层,秒辨渲染慢与等待慢
android·性能优化·实战·源码分析·渲染优化·gpu呈现模式·卡顿优化
91刘仁德10 小时前
MYSQL 事务原理及使用
android·mysql·adb
一笑的小酒馆12 小时前
AndroidKMP之瀑布流实现
android
RainyJiang12 小时前
AI时代下,Android的边界正在消失
android·openai·ai编程
2601_9622946112 小时前
Python开发工具哪个好?Python开发工具推荐
ide·文本编辑器·游戏开发·编程语言·python开发工具