ygu
ygu

Reputation: 47

Android - "Execution Failed, java.exe finished with non-zero exit value 2" when trying to integrate Twitter Fabric

I installed Fabric in my project using Android Studio's Fabric plugin. It prevented a lot of other bugs I was getting, but I still get java.exe finishing poorly. I tried out all the other links on java.exe exiting with value 2, and nothing helped or was applicable.

Here's my build.gradle

buildscript {
repositories {
    maven { url 'https://maven.fabric.io/public' }
}

dependencies {
    classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
    maven { url 'https://maven.fabric.io/public' }
}


android {
    compileSdkVersion 21
    buildToolsVersion "22.0.1"

defaultConfig {
    applicationId "com.example.youtubemaster"
    minSdkVersion 11
    targetSdkVersion 21
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
}
}

dependencies {
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:support-v4:21.0.3'
compile 'com.android.support:recyclerview-v7:21.0.3'
compile 'com.google.code.gson:gson:2.3.1'
compile ('com.facebook.android:facebook-android-sdk:4.0.0')
        {
            exclude group: 'com.google.android', module: 'support-v4'
        }
compile files('libs/picasso-2.5.2.jar')
compile files('libs/retrofit-1.9.0.jar')
compile files('libs/YouTubeAndroidPlayerApi.jar')
compile('com.twitter.sdk.android:twitter:1.4.0@aar') {
    transitive = true;
}
}

Upvotes: 0

Views: 282

Answers (2)

Debanjan
Debanjan

Reputation: 2836

Since you are using Twitter sdk, which already contains Retrofit and gson, you will have to remove the following from your gradle

compile 'com.google.code.gson:gson:2.3.1' compile files('libs/retrofit-1.9.0.jar')

I too had the problem.

Upvotes: 1

Simon
Simon

Reputation: 19938

I ran into the same problem now and fixed it by enabling multidex.

https://developer.android.com/tools/building/multidex.html#mdex-gradle

Add this into your build.gradle:

defaultConfig {

    // Enabling multidex support.
    multiDexEnabled true
}


dependencies {
/*    Enabling multidex*/
    compile 'com.android.support:multidex:1.0.0'
}

Add this into your manifest:

<!--Supporting multidex-->
    <application
        android:name="android.support.multidex.MultiDexApplication" >

You will need multidex when you have exceeded your method count of 65536 which is actually quite easy to do if you add different libraries onto your build.gradle.

Upvotes: 0

Related Questions