FlikFlak
FlikFlak

Reputation: 197

Android Studio build Errors

I have been trying allot to fix this problem. I cant figure out what to do, i get stuck on the following output error when i want to debug the project.

Execution failed for task ':inspectoratecalculator:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\Users\FlikFlak\AppData\Local\Android\android-studio\sdk\build-tools\android-4.4.2\dx.bat --dex --output 
C:\Users\FlikFlak\AndroidStudioProjects\Inspectorate\inspectoratecalculator\build\dex\debug
C:\Users\FlikFlak\AndroidStudioProjects\Inspectorate\inspectoratecalculator\build\classes\debug 
C:\Users\FlikFlak\AndroidStudioProjects\Inspectorate\inspectoratecalculator\build\dependency-cache\debug 
C:\Users\FlikFlak\AndroidStudioProjects\Inspectorate\inspectoratecalculator\build\pre-dexed\debug\android-support-v4-9fdb020c999e0f186e4aef883e8a4b8676e1e3ac.jar 
C:\Users\FlikFlak\AndroidStudioProjects\Inspectorate\inspectoratecalculator\build\pre-dexed\debug\classes-3cbf09a1ad548c6398f541ca3aae99491954a4cd.jar 
C:\Users\FlikFlak\AndroidStudioProjects\Inspectorate\inspectoratecalculator\build\pre-dexed\debug\support-v4-19.1.0-ce3af6ab4e02f6c952693d6706242484504a4302.jar

Error Code:
    2
Output:
    UNEXPECTED TOP-LEVEL EXCEPTION:
    com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
        at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:594)
        at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:552)
        at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:533)
        at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:170)
        at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
        at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439)
        at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287)
        at com.android.dx.command.dexer.Main.run(Main.java:230)
        at com.android.dx.command.dexer.Main.main(Main.java:199)
        at com.android.dx.command.Main.main(Main.java:103)

-------------------------------------BUILD.GRADLE-----------------------------------

    apply plugin: 'android'

configurations {
    all*.exclude group: 'com.android.support', module: 'support-v4'

}

android {
    compileSdkVersion 19
    buildToolsVersion "19.0.3"

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile 'com.android.support:appcompat-v7:+'

compile fileTree(dir: 'libs', include: ['*.jar'])

Upvotes: 0

Views: 1134

Answers (3)

Jiejing Zhang
Jiejing Zhang

Reputation: 1050

I'm not sure you have same issue with me, but my issue is I use a JDK 1.8 to compile the code, which not supported by android dx tools.

The fix is change the SDK path from 1.8 to a 1.7 JDK in Project's Module Settings.

Reference this for detail config in Mac: https://stackoverflow.com/a/24680375/1043032

Upvotes: 0

Gagandeep Singh
Gagandeep Singh

Reputation: 17453

This may occur because your have same jar referenced during building of project multiple time , may be that jar is already included some other module or library module.double check and make sure that this condition does not exist.

We have faced this kind of problem earlier.

Upvotes: 0

Larry Schiefer
Larry Schiefer

Reputation: 15775

Remove the v4 JAR file from your project/module jar directory as @rupps mentioned. Also remove your "excludes" piece from the configuration. Because you're using the the appcompat-v7 dependency, you will automatically pick up the v4 support library via Maven.

Upvotes: 1

Related Questions