I've been trying to build my android app with gradle build, and to get it download required dependencies and jar files automatically, I added in my settings.gradle
apply plugin: 'com.android.application'
apply plugin: 'com.android.library'
And my build.gradle looks like this
plugins {
// Apply the application plugin to add support for building a CLI application in Java
}
repositories {
google()
mavenCentral()
}
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter:5.8.1'
implementation 'com.google.guava:guava:30.1.1-jre'
classpath 'com.android.tools.build:gradle:7.1'
}
application {
mainClass = 'MyProject.App'
}
tasks.named('test') {
useJUnitPlatform()
}
When I try running gradle build, I get an error:
A problem occurred while evaluating settings 'MyProject'.
> Plugin with id 'com.android.application' not found.
I did some research, and every answer on the Internets says it's probably due to the plugin version, so I tried solving the problem by using versions 4.1, 4.2, 7.1, and 7.0 for of 'com.android.tools.build:gradle', with no avail.
You are adding plugins in wrong place.
Plugins are added inside app/build.gradle
and classpaths are added inside the root (project) /build.gradle
.
For example, inside app/build.gradle
apply plugin: 'com.android.application'
buildscript {
repositories {
mavenCentral()
}
dependencies { }
}
Inside (root)/build.gradle
dependencies{
classpath 'com.android.tools.build:gradle:7.1'
}