I have added a baseline profile module to my android project following the instructions on the android developers official documentation here. I am getting an org.gradle.api.plugins.UnknownPluginException here.
The wizard in Android Studio adds the following lines to project level build.gradle file
plugins{
id 'com.android.test' version '8.4.0' apply false
id 'org.jetbrains.kotlin.android' version '1.9.22' apply false
id 'androidx.baselineprofile' version '1.2.3' apply false
id 'com.android.application' version '8.4.0' apply false
}
When I try to gradle sync I am getting the following error
Exception is:
org.gradle.api.plugins.UnknownPluginException: Plugin [id: 'com.android.test', version: '8.4.0', 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.test:com.android.test.gradle.plugin:8.4.0')
Searched in the following repositories:
Gradle Central Plugin Repository <98 internal lines>
at org.jetbrains.plugins.gradle.model.ProjectImportAction.doExecute(ProjectImportAction.java:117)
at org.jetbrains.plugins.gradle.model.ProjectImportAction.execute(ProjectImportAction.java:91)
at org.jetbrains.plugins.gradle.model.ProjectImportAction.execute(ProjectImportAction.java:39)<84 internal lines>
How can I resolve this issue?
So I finally found a solution. For some reason, gradle could not pick up the plugin from the repositories mentioned in buildscript
inside my project level build.gradle
. The solution was to add all of my plugin repositories to the top of settings.gradle
file.
pluginManagement {
repositories {
google()
mavenCentral()
maven {
url 'https://maven.google.com/'
name 'Google'
}
maven { url "https://plugins.gradle.org/m2/" }
gradlePluginPortal()
}
}
After adding the repositories under pluginManagement my project was finally able to sync and the plugins were imported.