This question already has an answer here:
这个问题已经有了答案:
- Error:(6, 0) Gradle DSL method not found: 'google()' 3 answers
- 错误:(6,0)Gradle DSL方法未找到:'谷歌()' 3答案。
When using google() as a repository on gradle with the plugin 2.3.3 on Android Studio 2.3.3 I get the following error:
当使用谷歌()作为一个存储库时,在Android Studio 2.3.3上使用插件2.3.3,我得到以下错误:
Error:(18, 0) Gradle DSL method not found: 'google()'
Possible causes:<ul><li>The project 'MyProject' may be using a version of the Android Gradle plug-in that does not contain the method (e.g. 'testCompile' was added in 1.1.0).
<a href="fixGradleElements">Upgrade plugin to version 2.3.3 and sync project</a></li><li>The project 'MyProject' may be using a version of Gradle that does not contain the method.
<a href="openGradleSettings">Gradle settings</a></li><li>The build file may be missing a Gradle plugin.
<a href="apply.gradle.plugin">Apply Gradle plugin</a></li>
How can I fix this?
我怎么解决这个问题?
Thanks.
谢谢。
1 个解决方案
#1
2
If you are using
如果您使用的是
- Android Studio 3.x
- Android Studio 3. x
- the android gradle plugin 3.x
- android gradle插件3。x。
- gradle v.4
- gradle v.4
then you can use the shortcut google()
.
然后可以使用快捷键谷歌()。
Example:
例子:
allprojects {
repositories {
jcenter()
google()
}
}
Otherwise with older version you can use maven { url 'https://maven.google.com' }
否则,你可以使用maven {url 'https://maven.google.com'}
For example:
例如:
allprojects {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
}
}
#1
2
If you are using
如果您使用的是
- Android Studio 3.x
- Android Studio 3. x
- the android gradle plugin 3.x
- android gradle插件3。x。
- gradle v.4
- gradle v.4
then you can use the shortcut google()
.
然后可以使用快捷键谷歌()。
Example:
例子:
allprojects {
repositories {
jcenter()
google()
}
}
Otherwise with older version you can use maven { url 'https://maven.google.com' }
否则,你可以使用maven {url 'https://maven.google.com'}
For example:
例如:
allprojects {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
}
}