1

i've some error with my project. I'm Android beginner. When I try to compile my app I get a following error

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_25\bin\java.exe'' finished with non-zero exit value 2

I'm using Parse SDK for login with Facebook,but in this moment,i've only this code in my app:

 protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    // [Optional] Power your app with Local Datastore. For more info, go to
    // https://parse.com/docs/android/guide#local-datastore
    Parse.enableLocalDatastore(this);

    Parse.initialize(this);

my build.gradle is:

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
    applicationId "com.example.daniele.myapplication"
    minSdkVersion 15
    targetSdkVersion 23
    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:23.1.1'
    compile 'com.parse.bolts:bolts-android:1.+'
    compile 'com.parse:parse-android:1.+'
  }

How can I solve it? First answer of this doesn't work for me: java.exe finished with non-zero exit value 2 when using Facebook SDK Many thanks.

EDIT: I solved it,for now. I deleted 'com.parse:parse-android:1.+' from dependecies and it works. I don't know why,but in the parse's tutorial,it suggest to add all of this dependencies

Community
  • 1
  • 1
minimanimo
  • 35
  • 1
  • 2
  • 9
  • 2
    Scroll higher in the Gradle console transcript, above where you have that error, and you will find the actual source of your problem. – CommonsWare Dec 28 '15 at 14:03
  • 1
    I solved it,for now. I deleted 'com.parse:parse-android:1.+' from dependecies and it works. I don't know why,but in the parse's tutorial,it suggest to add all of this dependencies – minimanimo Dec 28 '15 at 14:11
  • Don't you need com.parse:parse-android:1.+ for Parse? When I deleted mine, I got a lot more compiler errors – committedandroider Jan 24 '16 at 07:52
  • Found cause and solution, at least for me, I added answer here: http://stackoverflow.com/a/35045501/3397345 – Davideas Jan 27 '16 at 18:48

3 Answers3

7
 defaultConfig {
    applicationId "com.minls.cmn"
    minSdkVersion 11
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
    multiDexEnabled true

}
**dexOptions {
    javaMaxHeapSize "4g"**
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_7
    targetCompatibility JavaVersion.VERSION_1_7
}

put just this line dexOptions { javaMaxHeapSize "4g" }

Ashish Tikarye
  • 850
  • 8
  • 11
0

It seems that you are using Oracle's JDK version 8 which is based on Java 8 that is not officially supported by Android. More details here : https://stackoverflow.com/a/23318269/3535408.

Some tweaks exist but I do not recommend them. Stick to Java 7 and JDK 7 and you are good to go.

To change the JDK usage : Go to File > Project Structure > SDK Location > and change the JDK for JDK 7. You can download last version of JDK 7 here : http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html

Once I tried to add a Java Library that was compiled using JDK 8 in another IDE (NetBeans). I did not use any Java 8 features such as lambdas in this library but it was enough for Gradle to complain. So back in NetBeans, I changed the settings so that it compiles with JDK 7 and there my problem was solved !

Hope it helps !

Community
  • 1
  • 1
Mackovich
  • 3,319
  • 6
  • 35
  • 73
0

If the above error occurs in Spring Boot Gradle project, please restart your system and check again. It is due to the memory issue.

Kawsikan
  • 11
  • 3