// Top-level build file where you can add configuration options common to all sub-projects/modules.
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
}
buildscripts {
repositories {
google()
}
dependancies {
classpath 'com.google.gms:google-services:4.3.10'
}
}
allprojects {
repositories {
google()
}
}
The above code is my project level gradle.build file. The error that keeps occurring is that it is not able to find a method known as buildscripts(). I have very little experience with gradle and have almost 0 idea what I could even try.
In your Gradle file, all buildscript {} blocks must appear before any plugins {} blocks in the script. So your file should look like this:
buildscripts { //👈 Added on top of the file.
repositories {
google()
}
dependancies {
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
}
allprojects {
repositories {
google()
}
}
Related
i have tried to implement the following library in my android studio project but it does not download the implementation.
implementation 'androidmads.library.qrgenearator:QRGenearator:1.0.4'
implementation 'com.google.zxing:core:3.3.2'
from this
my gradle(project) file is
buildscript {
repositories {
mavenCentral()
maven { url "https://jitpack.io"}
// Check that you have the following line (if not, add it):
google() // Google's Maven repository
}
dependencies {
classpath 'com.google.gms:google-services:4.3.13'
}
}
// 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
id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin' version '2.0.0' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
my gradle setting file is:
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
maven { url "https://jitpack.io" }
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url "https://jitpack.io"}
}
}
rootProject.name = "Vehicle Rental"
include ':app'
i dont know what i am missing any help?
For android project created with gradle 7.2, the project gradle is very different from the previous ones, it now only contains these
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.1.2' apply false
id 'com.android.library' version '7.1.2' apply false
id 'org.jetbrains.kotlin.android' version '1.6.10' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
The settings.gradle is also very different from before, it now contains more configurations with the following
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
// classpath 'com.google.gms:google-services:4.3.10'
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
rootProject.name = "My App"
include ':app'
Where can I add the classpath for classpath 'com.google.gms:google-services:4.3.10'? When I add this to the settings.gradle, it fails to compile with error: "Could not find method classpath() for arguments [com.google.gms:google-services:4.3.10] on repository container of type org.gradle.api.internal.artifacts.dsl.DefaultRepositoryHandler"
I think with gradle version 7.2 you don't really need to specify the classpath, check doc1, doc2. Just insert plugin id on project level build.gradle:
plugins {
...
id "com.google.gms.google-services" version "4.3.10" apply false
}
and don't forget to copy-paste it on app level build.gradle:
plugins {
...
id "com.google.gms.google-services"
}
To check if the plugin is applied correctly, you can print the list of available plugins from another answer.
https://docs.gradle.org/7.2/userguide/plugins.html#sec:applying_plugins_buildscript Example 13. Applying a plugin with the buildscript block
buildscript {
repositories {
gradlePluginPortal()
}
dependencies {
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5'
}
}
apply plugin: 'com.jfrog.bintray'
paste code for your build-script class file in project-level gradle.build file, here is an example :
/**
* project-level - build.gradle file -- make sure buildscript is before
* plugins
**/
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.google.dagger:hilt-android-gradle-plugin:2.41'
}
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.1.3' apply false
id 'com.android.library' version '7.1.3' apply false
id 'org.jetbrains.kotlin.android' version '1.6.20' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
add setting.gradle like this
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
jcenter() // Warning: this repository is going to shut down soon
maven { url "https://jitpack.io" }
maven { url "https://android-sdk.tapdaq.com" }
}
}
rootProject.name = "App Name"
include ':app'
buils.gradle(project level)
buildscript {
ext.kotlin_version = "1.6.10"
ext.kotlincoroutine_version = '1.5.1'
ext.coroutineadapter_version = '0.9.2'
ext.gradle_version = '3.5.0'
ext.retrofit_version = '2.9.0'
ext.gson_version = '2.8.7'
ext.okhttp_version = '4.9.0'
ext.glide_version = '4.12.0'
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.4"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
I want to add dagger-hilt plugin to project.
classpath 'com.google.dagger:hilt-android-gradle-plugin:2.40.5'
https://developer.android.com/studio/preview/features#settings-gradle
plugins {
id 'com.android.application' version '7.1.0-beta02' apply false
id 'com.android.library' version '7.1.0-beta02' apply false
id 'org.jetbrains.kotlin.android' version '1.5.30' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
rootProject.name = 'GradleManagedDeviceTestingNew'
include ':app'
This is the correct to using the classpath in bumblebee
Use buildscript before plugins it will work and put your classpath there in the dependencies block
buildscript {
dependencies {
classpath("com.google.dagger:hilt-android-gradle-plugin:2.40.5")
}
}
plugins {
id 'com.android.application' version '7.1.0-rc01' apply false
id 'com.android.library' version '7.1.0-rc01' apply false
id 'org.jetbrains.kotlin.android' version '1.5.30' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
You should add a resolutionStrategy to settings.gradle as below.
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
resolutionStrategy {
eachPlugin {
if (requested.id.id == 'dagger.hilt.android.plugin') {
useModule("com.google.dagger:hilt-android-gradle-plugin:2.40.5")
}
}
}
}
Then, add the hilt plugin as below to the module level build.gradle file, it was updated correctly.
plugins{
*****
id 'dagger.hilt.android.plugin'
}
When creating a new project in AS BubmleBee the dependencies block is missing in top-level gradle file
To resolve adding classpath dependencies you should add the following block within the buildscript block.
dependencies {
classpath "com.google.dagger:hilt-android-gradle-plugin:2.40.5"
}
Add the following id in the plugins section of the top level gradle file:
id 'com.google.dagger.hilt.android' version '2.42' apply false
Credits to this SO answer
Project sync failed with the following errors.
Failed to resolve: play-services-auth
Open File
Failed to resolve: firebase-core
Open File
Tried replacing google() with maven { url "https://maven.google.com" } but no luck. Here is the content of build.gradle files.
build.gradle (app)
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
//google()
maven { url "https://maven.google.com" }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
plugins {
id 'com.onesignal.androidsdk.onesignal-gradle-plugin' version '0.7.0'
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
//apply plugin: 'com.google.gms.google-services'
android {
//other codes
}
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
//other codes
}
apply plugin: 'com.google.gms.google-services'
build.gradle(project)
buildscript {
repositories {
jcenter()
maven { url "https://maven.google.com" }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.google.gms:google-services:3.2.0'
}
}
allprojects {
repositories {
jcenter()
maven { url 'https://jitpack.io' }
maven { url "https://maven.google.com" }
mavenCentral()
}
}
ext {
minSdkVersion = 16
targetSdkVersion = 27
compileSdkVersion = 27
//Other code
}
task clean(type: Delete) {
delete rootProject.buildDir
}
If I put apply plugin: 'com.google.gms.google-services' just below apply plugin: 'io.fabric' I get the following errors
Could not find com.google.android.gms:play-services-auth-license:11.6.0.
Searched in the following locations:
https://jcenter.bintray.com/com/google/android/gms/play-services-auth-license/11.6.0/play-services-auth-license-11.6.0.pom
https://jcenter.bintray.com/com/google/android/gms/play-services-auth-license/11.6.0/play-services-auth-license-11.6.0.aar
https://jitpack.io/com/google/android/gms/play-services-auth-license/11.6.0/play-services-auth-license-11.6.0.pom
https://jitpack.io/com/google/android/gms/play-services-auth-license/11.6.0/play-services-auth-license-11.6.0.aar
https://maven.google.com/com/google/android/gms/play-services-auth-license/11.6.0/play-services-auth-license-11.6.0.pom
https://maven.google.com/com/google/android/gms/play-services-auth-license/11.6.0/play-services-auth-license-11.6.0.aar
https://repo.maven.apache.org/maven2/com/google/android/gms/play-services-auth-license/11.6.0/play-services-auth-license-11.6.0.pom
https://repo.maven.apache.org/maven2/com/google/android/gms/play-services-auth-license/11.6.0/play-services-auth-license-11.6.0.aar
https://maven.fabric.io/public/com/google/android/gms/play-services-auth-license/11.6.0/play-services-auth-license-11.6.0.pom
https://maven.fabric.io/public/com/google/android/gms/play-services-auth-license/11.6.0/play-services-auth-license-11.6.0.aar
Required by:
project :app > com.google.android.gms:play-services-auth:11.4.2
Did you generate the google-services.json file from the firebase under the project>app and add all the plugins at the bottom
In your build.gradle where you reference 'com.facebook.android:account-kit-sdk:4.+'
Please use 'com.facebook.android:account-kit-sdk:4.23.0'
instead of 'com.facebook.android:account-kit-sdk:4.+'
I am trying to use Crashlytics in my app but keep getting an error saying
Error:(30, 1) A problem occurred evaluating root project 'CodeX_TeaXt'.
Could not find method buildscripts() for arguments [build_dujqhmp6npuv4v2dkd04dm37r$_run_closure3#30d25365] on root project 'CodeX_TeaXt' of type org.gradle.api.Project.
And here's my code for the build.gradle file :
allprojects {
repositories {
google()
jcenter()}
}
task clean(type: Delete) {
delete rootProject.build``Dir}
buildscripts{
repositories {
// ...
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
// ...
classpath 'io.fabric.tools:gradle:1.24.4'
}
}
And:
allprojects {
// ...
repositories {
// ...
maven {
url 'https://maven.google.com/'
}
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
dependencies {
// ...
compile('com.crashlytics.sdk.android:crashlytics:2.7.1#aar') {
transitive = true
}
compile 'com.google.firebase:firebase-core:11.6.2'
}
I am also having a problem using performance, test lab, so help
You should move:
maven {
url 'https://maven.google.com/'
}
from you app-level build.gradle to you project-level build.gradle based on the instructions in: https://firebase.google.com/docs/crashlytics/get-started