Android:播放服务问题

时间:2016-10-05 09:57:14

标签: android android-gradle google-play-services

我想在添加

时在我的项目中添加Google Play服务

编译'com.google.android.gms:播放服务:8。+'

或更低版本我的项目工作正常

当我添加

com.google.android.gms:play-services:9。+ com.google.android.gms:play-services:9.6。 1

我收到错误,错误是:

 Error:The number of method references in a .dex file cannot exceed 64K.
Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html
:app:transformClassesWithDexForDebug FAILED
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_101\bin\java.exe'' finished with non-zero exit value 2

然而,当我使用上述声明时,它可以解决问题,有人可以解释或给我一个解决方法!!

Gradle文件

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.2"
    defaultConfig {
        applicationId "MyPackageName"
        minSdkVersion 15
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.2.0'
    compile 'com.google.android.gms:play-services:9.6.1'
   //i tried 9.+ still receiving same error and also enabled the multidex option but failed



}

2 个答案:

答案 0 :(得分:1)

使用Google Play服务库时

enter image description here。 首先,请参阅此链接:https://developers.google.com/android/guides/setup

答案 1 :(得分:0)

在build.gradle的底部添加此行。      在模块级别

apply plugin: 'com.google.gms.google-services'

和 在项目级别

  classpath 'com.google.gms:google-services:3.0.0