-3

I followed the guide from this question: Android Studio - UNEXPECTED TOP-LEVEL EXCEPTION:

but it still refuses to compile correctly, I've tried looking for the duplicate entries but cannot find it, the error is as follows

Error:Execution failed for task ':app:dexDebug'. com.android.ide.common.internal.LoggedErrorException: Failed to run command:
    C:\Users\ShadowFox\Android-sdk\build-tools\21.1.1\dx.bat --dex --output C:\Work\SystemMonitor - version 4.0\app\build\intermediates\dex\debug --input-list=C:\Work\SystemMonitor - version 4.0\app\build\intermediates\tmp\dex\debug\inputList.txt
Error Code:
    2
Output:
    UNEXPECTED TOP-LEVEL EXCEPTION:
    com.android.dex.DexException: Multiple dex files define Landroid/support/v7/app/ActionBar$Callback;
        at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
        at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
        at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
        at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
        at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
        at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
        at com.android.dx.command.dexer.Main.runMonoDex(Main.java:302)
        at com.android.dx.command.dexer.Main.run(Main.java:245)
        at com.android.dx.command.dexer.Main.main(Main.java:214)
        at com.android.dx.command.Main.main(Main.java:106)

Then for my Module:app build.gradle I have

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.1"

    defaultConfig {
       applicationId "edu.fiu.cis.visa.systemmonitor"
        minSdkVersion 19
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile files('libs/dropbox-android-sdk-1.6.3.jar')
    compile files('libs/httpmime-4.0.3.jar')
    compile files('libs/json_simple-1.1.jar')
    compile project(":libs:AndroidCommon")
}

and my library's build.gradle is as follows

apply plugin: 'com.android.library'

dependencies {
    compile 'com.android.support:support-v4:21.0.3'
}

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 22
    }

 >   sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            res.srcDirs = ['res']
        }
    }

    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile files('libs/gson-2.2.2.jar')
        compile files('libs/jackson-all-1.9.11.jar')
        compile files('libs/RootTools-3.4.jar')
    }
} 
Community
  • 1
  • 1
Eddi3
  • 59
  • 1
  • 8
  • 2
    `Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompatIcs`You seem to have conflicts in your dependencies. That message means that you have more than one definitions of this class and the system does not know which one to choose from. Please show us the `gradle.build` file – George Daramouskas Jun 29 '15 at 18:13
  • Can you post your build.gradle ? – Soham Jun 29 '15 at 18:25
  • just edit the build.grade – Eddi3 Jun 29 '15 at 18:26
  • @Eddi3 ,it's not properly formatted.It's creating a lot confusion – Soham Jun 29 '15 at 18:37
  • how do I properly format it? I tried using the annotations in the box and then copy and paste straight from android studio console but it messes up the indentation – Eddi3 Jun 29 '15 at 18:39
  • I have done editing,just accept it. – Soham Jun 29 '15 at 18:40

2 Answers2

0

The library com.android.support:appcompat-v7 is fetched both times. Remove the first one.

You fetch the library, and then your library's build.gradle fetches it again

George Daramouskas
  • 3,720
  • 3
  • 22
  • 51
  • Are you sure? because I commented one out if you see it, it has the // behind it so it's commented out – Eddi3 Jun 29 '15 at 18:31
  • Edited so no one gets confused, that's what I have now – Eddi3 Jun 29 '15 at 18:33
  • Make sure you hit `Save` on the file in order for the filesystem to update it, and also run `gradle --refresh-dependecies` in order to clean the cache and re-fetch the dependencies. – George Daramouskas Jun 29 '15 at 18:37
  • `Ok, so in the latest version of Android Studio 0.1.3, they've added a Gradle project refresh button next to the other Android specific buttons in the toolbar. Make changes manually to the build.gradle files and settings.gradle and then click this button. It should configure and refresh your project settings based on the gradle files.` There is a button in android studio that refreshes the gradle dependencies. Find it and click it. – George Daramouskas Jun 29 '15 at 18:43
  • yea I already did that but it still giving me this compile error – Eddi3 Jun 29 '15 at 18:45
  • wait I just restarted android studio after doing your step and it's working :D thanks – Eddi3 Jun 29 '15 at 18:45
  • nevermind, it's still not working :/ my bad I thought it was fixed but I still get the same error – Eddi3 Jun 29 '15 at 18:50
0

try this

in the app:build.gradle

defaultConfig {
        applicationId "edu.fiu.cis.visa.systemmonitor"
        minSdkVersion 19
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
        // Enabling multidex support.
        multiDexEnabled true
         }

And put it in the app:build.gradle file

android {
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
    }
}
Soham
  • 4,397
  • 11
  • 43
  • 71