简体   繁体   中英

Android build.gradle fail Android studio

I program with Android Studio.

Error message:

Error:Execution failed for task ':app:dexRelease'. com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\\Program Files\\Java\\jdk1.8.0_25\\bin\\java.exe'' finished with non-zero exit value 2

And my build.grandle :

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "theToolcome.theTool.theTool"
        minSdkVersion 15
        targetSdkVersion 22
        versionCode 4
        versionName "1.1"
    }
    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:22.0.0'
    compile 'com.google.android.gms:play-services-analytics:7.3.0'
}

I didn't change anything, I only added the Google analytics. What's my problem? I search also on the stackoverflow, but nothing worked for me.

I also imported the project again, but nothing helped me.

For everyone reading.

The problem was that he downloaded a sample from the internet that contained anaylitics jar file, and he also told Android Studio to compile it for him via compile 'com.google.android.gms:play-services-analytics:7.3.0' so the end effect was that there were two libraries with mostly the same classes and that failed the build.

As the official documentation states out, your applications method references have exceeded the maximum limit:

Note: If the number of method references in your app exceeds the 65K limit, your app may fail to compile. You may be able to mitigate this problem when compiling your app by specifying only the specific Google Play services APIs your app uses, instead of all of them. For information on how to do this, see Selectively compiling APIs into your executable.

Instead of importing the entire Google Play Services, you should import the part that you use.

So instead of compile 'com.google.android.gms:play-services-analytics:7.3.0' you could use compile 'com.google.android.gms:play-services-maps:7.3.0' , if what you want is GoogleMap API.

Check the Analytical Table and select the part that you want, then import it and you should be fine.

项目结构> JDK位置>将其更改为1.7版本的jdk。

In your message log you can scroll down to errors there can you see what the error is and maybe you can solve it at yourself. Otherwise one of the forum members can maybe help if you send the error.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM