使用谷歌()作为存储库不起作用 [英] Using google() as a repository doesn't work

查看:237
本文介绍了使用谷歌()作为存储库不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 

在Android Studio 2.3.3上使用插件2.3.3时,使用google()作为gradle上的存储库时,出现以下错误: code>错误:(18,0)未找到Gradle DSL方法:'google()'
可能的原因:< ul>< li>项目'MyProject'可能使用不包含该方法的Android Gradle插件(例如,在1.1.0中添加了'testCompile')。
< a href =fixGradleElements>将插件升级到版本2.3.3并同步项目< / a>< / li>< li>项目MyProject可能使用Gradle版本不包含该方法。
< a href =openGradleSettings> Gradle设置< / a>< / li>< li>构建文件可能缺少Gradle插件。
< a href =apply.gradle.plugin>应用Gradle插件< / a>< / li>

我该如何解决这个问题?

谢谢。

解决方案

如果您使用的是 b
$ b

    > Android Studio 3.x
  • android gradle插件3.x

  • gradle v.4



然后您可以使用快捷键 google()



示例:

  allprojects {
知识库{
jcenter()
google()


$ / code>

否则,在旧版本中,您可以使用例如:

  allprojects {
存储库{
jcenter()
maven {url'https://maven.google.com'}



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:

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.

解决方案

If you are using

  • Android Studio 3.x
  • the android gradle plugin 3.x
  • 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' }

For example:

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

这篇关于使用谷歌()作为存储库不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆