即时运行抛出DexIndexOverflowException [英] Instant Run throw DexIndexOverflowException
问题描述
在我的项目中将 targetSdkVersion 设置为 21 以下时,gradle构建可以正常工作,并且项目可以正常运行.这是build.gradle文件:
When targetSdkVersion is set below 21 in my project, gradle build works fine and project runs properly. Here is build.gradle file:
defaultConfig {
applicationId "com.air"
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
但是当 targetSdkVersion 设置为 23 并启用即时运行时,它将引发以下异常:
But when targetSdkVersion is set 23 and instant run is enabled, it throws this exception:
com.android.dex.DexIndexOverflowException:方法ID不在[0,0xffff]中:65536
com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
为什么?
即时运行让我有些困惑.我不清楚它在Android Studio中如何工作.
Instant Run is bit confusing to me. I am unclear how it works in Android Studio.
推荐答案
即时运行通过执行热交换,热交换或冷交换将更新的代码和资源推送到连接的设备或仿真器.它会根据您所做的更改类型自动确定要执行的交换类型.
Instant Run pushes updated code and resources to your connected device or emulator by performing a hot swap, warm swap, or cold swap. It automatically determines the type of swap to perform based on the type of change you made.
https://developer.android.com/studio/run/index.html#instant-run
这篇关于即时运行抛出DexIndexOverflowException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!