Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error:(6, 0) Gradle DSL method not found: 'google()'

/Users/Ren/Desktop/RecylerViewBaseAdapter/build.gradle Error:(6, 0) Gradle DSL method not found: 'google()' Possible causes: The project 'RecylerViewBaseAdapter' may be using a version of Gradle that does not contain the method. Gradle settings The build file may be missing a Gradle plugin. Apply Gradle plugin 
like image 932
VenRen Avatar asked Aug 20 '17 11:08

VenRen


People also ask

What is DSL in Gradle?

Simply, it stands for 'Domain Specific Language'. IMO, in gradle context, DSL gives you a gradle specific way to form your build scripts. More precisely, it's a plugin-based build system that defines a way of setting up your build script using (mainly) building blocks defined in various plugins.

What is Android Gradle DSL?

The Android Gradle Plugin (AGP) is the supported build system for Android applications and includes support for compiling many different types of sources and linking them together into an application that you can run on a physical Android device or an emulator.

How do I connect my Gradle to the Internet?

Gradle needs an internet connection to download the dependencies that you specify. Once it downloads everything, it can put them in memory so that you can work offline. To do this, you need to go to Files->Settings (For Mac: Android Studio-> Settings...). You can now build your project without internet.


2 Answers

The google() repo is a shortcut to look in Google's Maven repository for dependencies. It was introduced with gradle v.4.0.

It requires (currently)

  • Gradle v.4
  • Android Studio 3.x.
  • Gradle plugin for Android 3.x

Try to use in gradle-wrapper.properties use:

distributionUrl=\   https\://services.gradle.org/distributions/gradle-4.1-rc-1-all.zip 

As gradle plugin for Android use:

classpath 'com.android.tools.build:gradle:3.0.0-beta1' 

In any case (also with Android Studio 2.3, gradle plugin 2.3.3 and gradle v3.3) you can use the same maven repo using { url 'https://maven.google.com'}. It is the same.

Just use for example:

buildscript {     repositories {         maven {             url 'https://maven.google.com'         }         jcenter()         maven { url 'https://maven.fabric.io/public' }     }  // } 
like image 124
Gabriele Mariotti Avatar answered Oct 14 '22 07:10

Gabriele Mariotti


If you use Android studio 2.3.3, then try adding this in your project level gradle

allprojects {   repositories {     jcenter()     maven {         url 'https://maven.google.com'     } } 

this worked for me.

You also can use google() instead but you need Gradle 4.x+, Android Studio 3.x+ , Gradle plugin 3.x+

like image 45
Anonymous Avatar answered Oct 14 '22 05:10

Anonymous