When I create a new project (with the default settings, wasn’t modified) in the newest Android Studio version (no more updates available) I get this message:
Build file
‘C:UsersuserAndroidStudioProjectsMyApplicationbuild.gradle’
line: 3Plugin [id: ‘com.android.application’, version: ‘7.2.1’, apply: false] was not found in any of the following sources:
…
Exception is:
org.gradle.api.plugins.UnknownPluginException: Plugin [id: ‘com.android.application’, version: ‘7.2.1’, apply: false] was not found in any of the following sources:Gradle Core Plugins (plugin is not in ‘org.gradle’ namespace)
Plugin Repositories (could not resolve plugin artifact ‘com.android.application:com.android.application.gradle.plugin:7.2.1’)Searched in the following repositories:
Gradle Central Plugin Repository
MavenRepo
at org.jetbrains.plugins.gradle.model.ProjectImportAction.execute(ProjectImportAction.java:116)
at org.jetbrains.plugins.gradle.model.ProjectImportAction.execute(ProjectImportAction.java:42)
While I can open projects that were created with an older version just fine.
This is the default project structure:
build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.2.1' apply false
id 'com.android.library' version '7.2.1' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
app/build.gradle:
plugins {
id 'com.android.application'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.example.myapplication"
minSdk 23
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
settings.gradle:
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
rootProject.name = "My Application"
include ':app'
I tried to lower the APG and Gradle versions, reinstall Android Studio, reset to default settings, but it still fails.
How can I resolve this error?
3
Answers
Turned out to be a problem with the internet supply which blocked the access to the
google()
repository.Using hotspot solved the problem.
The message means that you are defining a dependency that can not be found in any of the repositories that are defined in
settings.gradle
. This file can be found in your project root folder.Maybe your gradle cache is having problems. Try to invalidate all caches in Android Studio and restart it: File -> Invalidate Caches -> Invalidate and Restart
Check following things:
in gradle-wrapper.properties
In android studio preferences
Build,Execut....>Build Tools>Gradle
SetUse Gradle from gradle-wrapper.properties file
andGradle JDK
to11