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

匿名 (未验证) 提交于 2019-12-03 01:55:01

问题:

/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 

回答1:

The google() repo is a shortcut to looks 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' }     }  // } 


回答2:

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+



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!