Error: Gradle: execution failed for task ':app:preDexDebug'

I had a self created jar from another projected imported as a library into my other project. When I changed code in that project and exported a new jar to replaced the old one I cannot run my app anymore. I only get the following error:

enter image description here

  • What are the possibilities to get this error code 3 in InApp purchase?
  • Can I use adb.exe to find a description of a phone?
  • How to make scrollable tab in Android?
  • How to Schedule Notification in Android
  • Getting a File's Last Modified Date
  • How is a context in Android created? What is the purpose of ContextThemeWrapper?
  • I have tried removing and adding and adding as dependency, adding as library. Nothing seems to work. I have also done clean build and a rebuild.

    Related posts:

    Dialog with transparent background in Android
    NoSuchMethodError using commonc codec in Android application
    Custom Animation for navigation drawer open and close
    How to build an APK file in Eclipse?
    `/storage/emulated/legacy/` vs `/storage/emulated/0/` vs `data/data/myApp'
    Google TV - is designing for efficiency as important as it is with handsets/tablets?
  • How to set onclicklistener button which is inside a custom dialog
  • how to hide photos from gallery and store it in my app
  • rewriting Java code to JS - creating an audio from bytes?
  • Gradle error “Attribute ”xxx“ has already been defined” in Android Studio
  • How to make the textview blinking
  • Encryption of video files?
  • 4 Solutions collect form web for “Error: Gradle: execution failed for task ':app:preDexDebug'”

    We’ve seen this problem in the past when our project was compiling with a version of Java different from the one used to compile the library. The magic number is just used to identify class files so that is not the problem here. The issue is the java version (0034.0000 == Java 8).

    The easiest thing to do is target Java 6, which may require removing newer syntax from your code. In our case, both the project and library were ours so we were able to add the following to force the version of Java that we needed:

    Android Libraries

    for android libraries, add this code to the “android” extension object:

    android {
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_6
            targetCompatibility JavaVersion.VERSION_1_6

    Java Libraries

    for java libraries, add this code at the “top level”:

    apply plugin: 'java'
    version '1.8.1'
    group   'com.yourcompany.package'
    sourceCompatibility = JavaVersion.VERSION_1_6   //these two lines
    targetCompatibility = JavaVersion.VERSION_1_6   //are the only ones that matter

    NOTE: the last two lines are the only ones that matter, I added the others just to show where those lines belong, in respect to the rest of your gradle build file.

    For us, this was caused by the Android SDK build-tools version. Got the problem on v23.x, but not v22.x. You need to uninstall v23 for cordova to pick v22.

    Possibly a symptom rather than a cause, but this may unstick someone in the same situation.

    Although your problem seems fixed, I ended up here with a similar error (while building the samples from In case it’s helpful to others, I was able to solve it by setting JAVA_HOME to the appropriate value. In my case it was:

    export JAVA_HOME=/usr/lib/jvm/java-6-openjdk-amd64


    sourceCompatibility = JavaVersion.VERSION_X_X
    targetCompatibility = JavaVersion.VERSION_X_X

    in the Android project gradle file and the Java library gradle file worked for me.

    Sorry I would have +1’d it but don’t have a high enough reputation

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.