0

build.gradle file:

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "xxxxx.com.myapp"
        minSdkVersion 9
        targetSdkVersion 22
        versionCode 3
        versionName "1.2"


    }
    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.1.1'
    compile 'com.google.android.gms:play-services-ads:7.3.0'
    compile files('libs/libGoogleAnalyticsServices.jar')
}

Error Log:

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':app:dexDebug'.

    com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_51\bin\java.exe'' finished with non-zero exit value 2

Diptendu Das
  • 3,990
  • 7
  • 22
  • 38
  • Are any of your dependencies conflicting? What jars do you have in libs? You are also adding `libGoogleAnalyticsServices.jar` twice since at the beginning you add all jars in your libs folder, then you explicitly add this one again at the end. Try removing it. – Zarwan Sep 03 '15 at 04:32
  • getting same error after removing compile files('libs/libGoogleAnalyticsServices.jar') – Diptendu Das Sep 03 '15 at 04:48
  • Can you post what jars are in your libs folder? Maybe there are more conflicts. – Zarwan Sep 03 '15 at 04:48
  • Only One jar in my Lib folder libGoogleAnalyticsServices.jar – Diptendu Das Sep 03 '15 at 06:12

3 Answers3

4

Try removing the following from your dependencies:

compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/libGoogleAnalyticsServices.jar')

If you look here, the Analytics API is already built into Google play services, so the two are conflicting.

Zarwan
  • 5,537
  • 4
  • 30
  • 48
2

Sometimes this build failed error occures due to multidex problem. As per looking into your build script it does not seems that you need multidex enabling ture. But still you can try this because I can not say much just seeing your gradle build script.Use

    defaultConfig {
            applicationId "xxxxx.com.myapp"
            minSdkVersion 9
            targetSdkVersion 22
            versionCode 3
            versionName "1.2"
            // enable Mutidex.
            multiDexEnabled true


        }
Mahendra Chhimwal
  • 1,810
  • 5
  • 21
  • 33
0

You are including libGoogleAnalyticsServices.jar twice. Based in the path, it will be include by the following line (which includes all jars in the libs directory) --

compile fileTree(dir: 'libs', include: ['*.jar'])

remove this line to avoid including the lib twice --

compile files('libs/libGoogleAnalyticsServices.jar')
iagreen
  • 31,470
  • 8
  • 76
  • 90
  • 1
    getting same error after removing compile files('libs/libGoogleAnalyticsServices.jar') – Diptendu Das Sep 03 '15 at 04:47
  • Try cleaning/rebuild after you do your gradle sync. in case the dependencies were cached. What other files do you have your libs directory? And can you grab more of that error, there is usually a stack trace above it. It will give you some guidance about what the issue is. – iagreen Sep 03 '15 at 04:49