Reputation: 490
After the Gradle update, every new project has this type of format in build.gradle (project:"...")
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.1.0' apply false
id 'com.android.library' version '7.1.0' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Now how can I add classpath dependencies here?
Upvotes: 9
Views: 14242
Reputation: 177
If you are adding firebase to your Android App it needs to look something like below.
buildscript {
repositories {
// Check that you have the following line (if not, add it):
google() // Google's Maven repository
}
dependencies {
// Add this line
classpath 'com.google.gms:google-services:4.3.10'
}
}
plugins {
id 'com.android.application' version '7.1.2' apply false
id 'com.android.library' version '7.1.2' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Upvotes: 11
Reputation: 16477
Just add a dependencies
section/method as shown in the gradle docs:
dependencies{
implementation 'group.id:artifact-id:version'
}
If a dependency should be available both at compile- and runtime, declare it as implementation
(not available for dependents) or api
(also available for dependents). See this for more details on the difference between api
and implementation
.
If it should be available at compile-time only, use compileOnly
.
Similarly, you can use runtimeOnly
for dependencies that should only be used at runtime.
If a dependency should be available only during tests, add test
before it, e.g. testImplementation
.
The docs on the Java Library Plugin provide more details on that.
Upvotes: 0