ben*_*daf 15 android android-build android-studio android-gradle-2.0 android-instant-run
我已经升级到Android Studio 2.1,当我尝试构建和运行我的企业大项目时,我遇到了这个错误:
任务':app:transformClassesWithDexForMyAppDebug'的执行失败.com.android.build.api.transform.TransformException:com.android.ide.common.process.ProcessException:java.util.concurrent.ExecutionException:java.lang.OutOfMemoryError:GC开销超过限制
我已经搜索了论坛并禁用了即时运行,也写入了我的build.gradle:
dexOptions {
incremental true
javaMaxHeapSize "6g"
}
...
dependencies{
compile 'com.android.support:multidex:'
}
Run Code Online (Sandbox Code Playgroud)
但它无法解决我的问题.我在gradle中启用了multidex,因为没有它我得到了错误:
com.android.dex.DexIndexOverflowException:方法ID不在[0,0xffff]中:65536
所以这是它的解决方案,它之前的Android Studio版本(也适用于公司的其他人,使用的是Android Studio 1.4-2.0),但是在我升级Android Studio之后却没有.
有谁知道会导致什么问题?
有趣的是,如果我只是做项目我没有得到错误,只有当我尝试运行它.任何想法都表示赞赏!
编辑1:
有趣的是,如果我重启我的android工作室,比第一次运行成功,但第二次运行不成功.
编辑2:
如果我将堆大小设置为更大(比如8-10g),那么应用程序甚至不会在第一次运行时编译.
编辑3:
似乎问题是即时运行,如果我强迫android studio不使用它(比如一次部署到两个设备或更改gradle.properties,如答案)错误消失.
Asp*_*cas 28
将其添加到您的gradle.properties文件中.
# The Gradle daemon aims to improve the startup and execution time of Gradle.
# When set to true the Gradle daemon is to run the build.
org.gradle.daemon=true
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
org.gradle.parallel=true
# Enables new incubating mode that makes Gradle selective when configuring projects.
# Only relevant projects are configured which results in faster builds for large multi-projects.
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:configuration_on_demand
org.gradle.configureondemand=true
Run Code Online (Sandbox Code Playgroud)
在这里找到
在我的build.gradle:
....
dexOptions
{
incremental false
javaMaxHeapSize "2048M"
preDexLibraries = false
}//end dexOptions
....
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11775 次 |
| 最近记录: |