android - 为 google play 服务设置 gradle 文件

标签 android gradle

我是android开发的新手。我想设置我的应用程序以接收位置更新,所以我将逐步按照谷歌开发教程进行操作。我在 list 文件等中创建了权限……但我对 gradle 文件有疑问。在谷歌教程上我读到我需要编译

'com.google.android.gms:play-services:8.1.18'

到我的模块 gradle 文件,所以我已经完成但无法同步 gradle 项目,它给了我错误:
Error(25, 0) gradle DSL method not found: 'compile()' The project 'name' may be using wrong version of Gradle that does not contain a method. The build file may be missing a Gradle plugin.

这是我的模块 gradle 文件:
apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.1"

defaultConfig {
applicationId "com.example.filip.whereismydevice"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
    minifyEnabled false
    proguardFiles getDefaultProguardFile('proguard-android.txt'),                     'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.1'
complie 'com.google.android.gms:play-services:8.1.18'
}

这是我的项目,主要的 gradle 文件:
  // Top-level build file where you can add configuration options common to              all sub-projects/modules.

 buildscript {
 repositories {
 jcenter()
 }
 dependencies {
 classpath 'com.android.tools.build:gradle:1.3.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
 jcenter()
}
}

所以,我不知道可能出了什么问题,我在互联网上寻找解决方案,但没有发现同样的错误。如果已经解决了这个问题。

最佳答案

complie 'com.google.android.gms:play-services:8.1.18'

应该
compile 'com.google.android.gms:play-services:8.1.0'

笔记:
  • 你拼错了 compile
  • Google Play 服务的最新版本是 8.1.0
  • 关于android - 为 google play 服务设置 gradle 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33243752/

    相关文章:

    gradle - gradle 中的库版本已降级

    android - 如果有调用权限,如何使应用程序与平板电脑兼容?

    android - 应用程序在启动时死亡

    androidannotations @AfterViews 没有调用并且 editText 为空

    java - Intellij Idea- Gradle : Execution failed for task ':compileJava'

    maven - Gradle 与 Maven 原型(prototype)相对应?

    android - 如何替换额外值?

    java - android pie 9.0 mobile:org.json.JSONException:类型为java.lang.String的值CLEARTEXT无法转换为JSONObject

    java - 通过Groovy脚本从 Artifactory 获取用于多个作业的最新内部版本号。

    java - 接收方类o.s.c.b.BootstrapApplicationListener $ CloseContextOnFailureApplicationListener未定义或继承impl