0

After upgrading to Android design tools 24, my project won't run anymore. It builds fine without any errors, but when I run it I get the error:

Error:Gradle: 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_102\bin\java.exe'' finished with non-zero exit value 1

This is my build.gradle file:

apply plugin: 'com.android.application'

apply plugin: 'realm-android'

android {

compileSdkVersion 24
buildToolsVersion "24.0.2"

defaultConfig {
    applicationId "com.example.don.mstp"
    minSdkVersion 15
    targetSdkVersion 24
    versionCode 1
    versionName "1.0"
    // Enabling multidex support.
    multiDexEnabled true
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}


buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
dexOptions {
    incremental true
    javaMaxHeapSize "4g"
    preDexLibraries = false
}


}

dependencies {

compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.github.Lukle:ClickableAreasImages:v0.1'
compile 'com.android.support:design:24.2.0'
compile 'com.android.support:support-v4:24.2.0'
compile 'com.android.support:cardview-v7:24.2.0'
compile 'com.android.support:recyclerview-v7:24.2.0'
compile 'com.github.javiersantos:MaterialstyledDialogs:1.3'
compile 'com.github.PhilJay:MPAndroidChart:v2.1.6'
compile 'com.ramotion.foldingcell:folding-cell:1.0.1'
compile 'com.github.brnunes:swipeablerecyclerview:1.0.2'
compile 'com.github.gabrielemariotti.recyclerview:recyclerview-animators:0.3.0-SNAPSHOT@aar'
compile 'com.tiancaicc.springfloatingactionmenu:library:0.0.2'
compile 'com.daimajia.numberprogressbar:library:1.2@aar'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.daprlabs.aaron:cardstack:0.3.0'
compile 'com.txusballesteros:FitChart:1.0'
compile 'com.github.SilenceDut:ExpandableLayout:v1.0.1'

}
Sifundo Moyo
  • 175
  • 1
  • 7
  • do you actually need multidex "compile 'com.android.support:multidex:1.0.1'" i highly doubt it, but you should see what dependencies your pulling into your app, most likely gradle fails cause you have a ton of dependencies, which most likely include others and i am sure you have duplicates included. run `./gradlew app:dependencies` to check from terminal in Android Studio – kandroidj Sep 09 '16 at 00:10
  • As per the android documentation : https://developer.android.com/studio/build/multidex.html , I need to add "compile 'com.android.support:multidex:1.0.0', went a step further and added the most recent. I am using Intellij, doesn't seem to have 'gradle console'. I am using a lot of dependencies and my guess is I may have exceeded 65K methods. Thanks for the prompt answer. – Sifundo Moyo Sep 09 '16 at 00:16
  • Do you get the error when you build debug only or also when you build release? Also, why have you turned off proguard `minifyEnabled false`, that should be enabled for both release and debug. – DataDino Sep 09 '16 at 01:36
  • Possible duplicate of [Android java.exe finished with non-zero exit value 1](http://stackoverflow.com/questions/29045129/android-java-exe-finished-with-non-zero-exit-value-1) – Amit Vaghela Sep 09 '16 at 04:14
  • I cannot specify your problem, but I would like to tell you that _Do not use support library x.x.0_ from Google. It almost always breaks build, makes crash, or gives unstable results. We always apply from _x.x.1_ version. That's what we've learnt from history. – Youngjae Sep 09 '16 at 04:53
  • It builds with no errors but does not run. After some digging around : Realm database relies on APT to generate its proxy classes. Realm doesn't only require the annotation processor but also the byte code manipulation (transform API) which is not supported by JACK. Am I on the right track in understanding that realm and jack can't work together? If so, any solutions as to how to get them working together? – Sifundo Moyo Sep 09 '16 at 07:18
  • update: I added jackOptions { enabled true } to gradle as per the Java 1.8 requirements. – Sifundo Moyo Sep 09 '16 at 07:26

1 Answers1

1

I finally got my project to run and this is how:

Apparently, It is not possible to use Jack compiler with Realm at the moment, because Jack does not support bytecode manipulation (Javassist / Transform API). That being said we can however for now use 'retrolambda' and remove jackOptions.

in your build.gradle

apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'realm-android'

compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
}

in the projects main gradle add class path:

 dependencies {
        classpath 'io.realm:realm-gradle-plugin:0.88.3'
        classpath 'me.tatarka:gradle-retrolambda:3.2.5'

    }

And that got my project running again.

Sifundo Moyo
  • 175
  • 1
  • 7