androidandroid-studiomigrationeclipse-adt

After import from Eclipse to Android Studio cannot run Execution failed for task ':app:dexDebug"


Have an Android project working in Eclipse (4.4.2) ADT, running on Linux (Ubuntu 14.10).

I have imported to Android Studio (1.1.0) and managed to get rid of my initial compilation errors.

The next thing I want to d is to run on my phone - I push the green "Run" button and after a little while I get an error (this doesn't show up when I just build module, only when I try to run)

The error is this:

Error:Execution failed for task ':myapp:dexDebug'. com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-7-openjdk-amd64/bin/java'' finished with non-zero exit value 2

Been looking through SO for the last 4 hours and not found anything that seems relevant to my project. Is there another place I can look to find a more useful error?

EDIT: Aaarghh - just recreated the entire project(rather than trusting the import wizard) - I created a new Android Studio project, imported my code and resources and then solved all the compilation and dependency errors. Got through to a clear build then tried to run....same damn error! Exactly the same. What am I doing wrong????

New build.gradle posted for reference:

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'

android {
compileSdkVersion 21
buildToolsVersion "21.1.1"

defaultConfig {
    applicationId "com.mycompany.app_Name"
    minSdkVersion 15
    targetSdkVersion 21
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

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

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
compile project(':swipeListView')
compile 'com.sothree.slidinguppanel:library:3.0.0'
compile files('libs/volley.jar')
compile files('libs/libGoogleAnalyticsServices.jar')
compile files('libs/commons-codec-1.8.jar')
compile files('libs/linkedin-j-android.jar')
compile files('libs/signpost-commonshttp4-1.2.1.1.jar')
compile files('libs/signpost-core-1.2.1.1.jar')
compile files('libs/twitter4j-core-4.0.1.jar')
compile files('libs/core.jar')
compile files('libs/gcm.jar')
compile 'com.google.android.gms:play-services:6.5.87'
compile 'com.facebook.android:facebook-android-sdk:3.20.0'
compile('com.crashlytics.sdk.android:crashlytics:2.2.2@aar') {
    transitive = true;
}
compile project(':myImportedProject')
}

Also tried to export as an APK with my keystore: got a similar error:

Error:Execution failed for task ':app:dexRelease'. com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-7-openjdk-amd64/bin/java'' finished with non-zero exit value 2


Solution

  • Aha!

    Seems the answer was further up in trace: The error was

    com.android.dex.DexException: Multiple dex files define Lcom/nineoldandroids/animation/Animator$AnimatorListener;

    So I found the answer here:

    ListViewAnimations Library Causes TOP-LEVEL-EXCEPTION

    Part of the trick is not only to add the line to build.gradle saying

    compile files('libs/nineoldandroids-2.4.0.jar')
    

    but also to remove the JAR from the libs directory.

    Now I have more linking issues but I'll leave them for another question I guess.