将buildToolsVersion 21.0.2更新到22.0.1时出错

时间:2015-06-03 14:57:54

标签: java android build-tools

最近补充说:

buildToolsVersion' 22.0.1'

我正在使用不同的productFlavors。

android {

    compileSdkVersion 22
    buildToolsVersion '22.0.1'

    defaultConfig {
        applicationId 'com.consulta'
        minSdkVersion 17
        targetSdkVersion 22
        versionCode 14
        versionName '1.0.11'
    }

    signingConfigs {
        release {
            storeFile file("keystore.jks")
            storePassword "******"
            keyAlias "MyAlias"
            keyPassword "******"
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
            signingConfig signingConfigs.release
        }
    }
    productFlavors {
        production {
            applicationId "com.app"
            resValue "string", "app_name", "MyApp"
            minSdkVersion 17
            targetSdkVersion 22
        }
        stage {
            applicationId "com.app.stage"
            resValue "string", "app_name", "MyApp.Stage"
            minSdkVersion 17
            targetSdkVersion 22
        }
        freeze {
            applicationId "com.app.freeze"
            resValue "string", "app_name", "MyApp.Freeze"
            minSdkVersion 17
            targetSdkVersion 22
        }
    }

    sourceSets {
        main {
            assets.srcDirs = ['src/main/assets', 'src/main/assets/']
        }
    }


}

dependencies {
 compile fileTree(dir: 'libs', include: ['*.jar'])
'com.android.support:appcompat-v7:22.0.0' 
}

以下是错误:

  

错误:任务':app:dexStageRelease'执行失败意外   顶级例外:

     

com.android.dex.DexIndexOverflowException:方法ID不在[0,   0xffff]:65536 at   com.android.dx.merge.DexMerger $ 6.updateIndex(DexMerger.java:502)
        在   com.android.dx.merge.DexMerger $ IdMerger.mergeSorted(DexMerger.java:277)         在com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:491)         在com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:168)
        在com.android.dx.merge.DexMerger.merge(DexMerger.java:189)at   com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)         在com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
        在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)

1 个答案:

答案 0 :(得分:0)

你已经找到了神话般的65k方法硬帽

https://developer.android.com/tools/building/multidex.html