android - 找不到方法 compile() google gms
问题描述
我正在尝试导入 google play services vision 但给我这个错误:
在 org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler 类型的对象上找不到参数 [com.google.android.gms:play-services-vision:15.0.2] 的方法 compile()。
构建gradle是:
// Top-level build file where you can add configuration options common
to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.2.51'
repositories {
google()
jcenter()
maven {
url "https://maven.google.com"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-
plugin:$kotlin_version"
classpath 'com.google.gms:google-services:15.0.2'
compile 'com.google.android.gms:play-services-vision:15.0.2'
// NOTE: Do not place your application dependencies here; they
belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven {
url "https://maven.google.com"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
谁能帮我?
解决方案
不要将您的应用程序依赖项放在顶层build.gradle
,而是使用模块级别app/build.gradle
来定义您的应用程序依赖项。
从此顶层删除此行build.gradle
并将其移至 app level build.gradle
。
compile 'com.google.android.gms:play-services-vision:15.0.2'
希望它能解决您的问题。
推荐阅读
- javascript - 监视文本文件中的更改,并在此文件不存在时进行处理
- vue.js - arcgis 草图模块不会安装到 DOM
- sql-server - 当前日期被多次返回?
- c++ - 如何根据引用修饰符进行深拷贝或浅拷贝?
- travis-ci - 在 travis 项目设置下找不到 SSH 密钥设置
- c# - 带有单个空格的意外正则表达式结果
- python-3.x - 为文本分类问题分离句子中的单词
- node.js - 找到更改节点版本的方法
- javascript - 如何使用 Node JS 下载在浏览器中的页面上打开的 html
- user-interface - 场景生成器预览显示比最终结果大得多的所有对象