最近补充说:
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)