在Android Studio

时间:2015-07-06 07:10:48

标签: android android-studio

我是Android Studio的新手。在构建项目时,我面临下面提到的错误。

:app:shrinkDebugMultiDexComponents FAILED
    Error:Execution failed for task ':app:shrinkDebugMultiDexComponents'.
    > java.io.IOException: Can't read [D:\StudioWorkspace\SampleSDKDemoProject\app\build\intermediates\multi-dex\debug\allclasses.jar] (Can't process class [org/fmod/FMODAudioDevice.class] (256))

这是app文件夹中的build.gradle文件。

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion '21.1.2'

    defaultConfig {
        applicationId "com.test.offerwall"
        minSdkVersion 9
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}


dependencies {
    compile 'com.bee7.gamewall.aar:bee7@aar'
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.google.android.gms:play-services-base:6.5.87'
    compile 'com.test.android.ads.aar:myapp@aar'
    compile 'com.google.android.gms:play-services:7.5.0'
}
repositories {
    flatDir {
        dirs 'libs'
    }
}

我已经更新了android sdk,但没有运气。你能帮帮我解决这个问题吗?

请帮助我解决问题。

提前致谢。

评论说:我尝试过删除 multiDexEnabled true 然后我收到了这个错误。

UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
    at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:502)
    at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:277)
    at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:491)
    at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:168)
    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:303)
    at com.android.dx.command.dexer.Main.run(Main.java:246)
    at com.android.dx.command.dexer.Main.main(Main.java:215)
    at com.android.dx.command.Main.main(Main.java:106)
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_45\bin\java.exe'' finished with non-zero exit value 2

1 个答案:

答案 0 :(得分:2)

对于第一个错误,请移除multiDexEnabled true

  

意外的顶级例外:

这个删除了一个com.google.android.gms:play-services个库,但它不止一次。

或在根级build.gradle添加此内容:

configurations {
    all*.exclude group: 'com.google.android.gms', module: 'play-services'
}
希望这会有所帮助。