[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

相关推荐
ANYOUZHEN2 小时前
bugku shell
android
0wioiw04 小时前
Onesignal(Xcode)
ide·macos·xcode
南宫码农5 小时前
我的电视 - Android原生电视直播软件 完整使用教程
android·开发语言·windows·电视盒子
道亦无名5 小时前
音频数据特征值提取 方法和步骤
android·音视频
Lancker6 小时前
定制侠 一个国产纯血鸿蒙APP的诞生过程
android·华为·智能手机·鸿蒙·国产操作系统·纯血鸿蒙·华为鸿蒙
2601_949809597 小时前
flutter_for_openharmony家庭相册app实战+通知设置实现
android·javascript·flutter
液态不合群8 小时前
【面试题】MySQL 中 count(*)、count(1) 和 count(字段名) 有什么区别?
android·数据库·mysql
雪球Snowball9 小时前
【Android关键流程】资源加载
android
2501_915918419 小时前
常见 iOS 抓包工具的使用,从代理抓包、设备抓包到数据流抓包
android·ios·小程序·https·uni-app·iphone·webview
zzh_my10 小时前
Visual Studio 2022介绍
ide·visual studio