Google在运行应用时会映射API和异常

时间:2017-01-03 06:00:38

标签: android google-maps

我正在开发包含Google地图的应用,因此我按照Google页面https://developers.google.com/maps/documentation/android-api/start中的说明进行操作

当我同步文件时,一切正常,但每次我尝试运行它时都有一个例外,说:

    Error:Execution failed for task 

':app:transformClassesWithDexForDebug'.
  > com.android.build.api.transform.TransformException: 
   com.android.ide.common.process.ProcessException: 
   org.gradle.process.internal.ExecException:
   Process 'command 'C:\Program    Files\Java\jdk1.8.0_31\bin\java.exe''   
   finished with non-zero exit value 3

这是我的傻瓜

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.example.tellme.mapwithmarker"
        minSdkVersion 18
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    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:23.2.0'
    compile 'com.google.android.gms:play-services:10.0.1'
    compile 'com.android.support:multidex:1.0.0'
}

直到现在项目中没有任何内容可以预期地图片段和主java类。

我将非常感谢您解决此错误的任何帮助。

感谢。

3 个答案:

答案 0 :(得分:0)

在gradle中添加以下buildTypes

dexOptions {
    // incremental true
    javaMaxHeapSize "4g"

}

答案 1 :(得分:0)

不要在项目中使用所有播放服务,而是使用所需的播放服务。

使用 编译'com.google.android.gms:play-services-maps:10.0.1'

而不是

编译'com.google.android.gms:play-services:10.0.1'

参考链接: https://developers.google.com/android/guides/setup

答案 2 :(得分:0)

您需要更改

 `compile 'com.google.android.gms:play-services:10.0.1'` 

`compile 'com.google.android.gms:play-services-maps:10.0.1'`

使用以下Gradle文件,它可以正常使用我已经检查过

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {

        applicationId "com.example.tellme.mapwithmarker"

        minSdkVersion 18
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    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:23.2.0'
   // compile 'com.google.android.gms:play-services:10.0.1'
    compile 'com.google.android.gms:play-services-maps:10.0.1'
    compile 'com.android.support:multidex:1.0.0'
}