프로세스에서 dex를 실행하려면 Gradle 데몬에 더 큰 힙이 필요합니다. 현재 약 910MB
내 앱을 실행할 때마다이 Gradle 오류가 발생합니다. 오류는 다음과 같습니다.
프로세스에서 dex를 실행하려면 Gradle 데몬에 더 큰 힙이 필요합니다. 현재 약 910MB가 있습니다.
더 빠른 빌드를 위해 Gradle 데몬의 최대 힙 크기를 2048MB 이상으로 늘립니다.
이렇게하려면 gradle.properties 프로젝트에서 org.gradle.jvmargs = -Xmx2048M을 설정합니다. 자세한 내용은 https://docs.gradle.org/current/userguide/build_environment.html을 참조 하십시오.
다음은 내 build.gradle (Module : app) 파일입니다.
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "mobileapp.tech2dsk"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:design:23.3.0'
}
그리고 여기 내 build.gradle (Project) 파일이 있습니다.
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
그리고 여기에 내 gradle.properties 파일이 있습니다.
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# 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
Build.gradle에 추가하십시오.
android {
dexOptions {
javaMaxHeapSize "4g"
}
}
추가 정보 -Android Gradle : javaMaxHeapSize "4g"란 무엇입니까?
2017 년 6 월 25 일 업데이트
Google IO 2017에서이 주제에 대한 몇 가지 업데이트가있었습니다. dexOptions에 플래그를 설정하는 것은 더 이상 권장되지 않으므로 다음과 같은 것이 있으면 삭제할 수 있습니다.
dexOptions {
javaMaxHeapSize "2g"
}
원래 답변 :
Android Studio 2.1은 빌드 시간을 개선하기 위해 Gradle과 VM을 공유하는 Dex In Process를 지원합니다. 이 때문에 이러한 Dex 프로세스를 통합하려면 Gradle 데몬의 크기를 늘려야합니다.
적어도 2GB의 메모리가 필요하지만 여유가 있다면 3GB로 시도해 볼 수 있습니다.
gradle.properties.
org.gradle.jvmargs=-Xmx3072m
기본적으로 Java 최대 힙 크기는 1 기가지만 build.gradle 파일에서 수정 한 경우 ...
build.gradle (앱)
dexOptions {
javaMaxHeapSize "2g"
}
... 그에 따라 Gradle 데몬 크기를 조정해야합니다 (힙에 맞게 더 커야 함).
메모:
- 위의 숫자는 기계마다 다릅니다.
gradle.properties에 그대로 두십시오.
org.gradle.jvmargs=-Xmx2048m
답변하기에는 너무 늦었지만 누군가에게 도움이되기를 바랍니다.
나는 많은 것을 시도하고 많이 검색했지만 나를 위해 작동하는 것은 다음을 포함하고 build.gradle (App) 도 내 경우에 작동하지 않습니다.
android {
dexOptions {
javaMaxHeapSize "4g"
}
}
또한 gradle.properties에 추가를 시도 할 수 있습니다 .
org.gradle.jvmargs=-Xmx2048m
제 경우 문제는 CPU 사용률입니다. apk를 빌드하는 동안 많은 프로세스가 실행되고 있습니다. genymotion, skype, safari 등과 같은 일부 프로세스를 죽이고 캐시를 무효화 / 다시 시작하는 것보다 작동합니다.
다음 디렉터리에서 gradle.properties라는 파일을 수정하거나 만듭니다.
Mac의 경우 /Users/USER_NAME/.gradle/gradle.properties
Linux의 경우 /home/USER_NAME/.gradle/gradle.properties
Windows의 경우 C : \ Users \ USER_NAME.gradle \ gradle.properties
위의 변경 사항을 적용하십시오. 마지막으로 다음과 같이 보일 것입니다.
org.gradle.daemon=true
# 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
org.gradle.configureondemand=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
이 링크를 참조하십시오 https://tausiq.wordpress.com/2015/02/24/android-speed-up-gradle-build-process-in-android-studio/
계속해서 그렇게 변경할 수 있습니다 build.gradle
(Veeresh Charantimath가 제안한 것처럼).
android {
dexOptions {
javaMaxHeapSize "2g"
}
}
그리고 MultiDex 물건 을 엉망으로 만들어야 할 수도 있습니다 (큰 안드로이드 프로젝트에 필요합니다). 그러나 문제는 더 간단 할 수 있습니다. 프로젝트에 필요하지 않은 라이브러리를 컴파일하고 포함 할 가능성이 있습니다. 내 작은 프로젝트에서이 문제에 직면했습니다. 내가 그것을 고치기 위해 한 일은 다음과 같습니다.
나는 이것을 다음에서 제거했습니다 build.gradle
.
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
And I manually removed my build folder from application root. Problem solved.
Is it an error or a warning?
Sometimes this is only a warning and I can manage to build it successfully:
:transformClassesWithDexForDebug
To run dex in process, the Gradle daemon needs a larger heap.
It currently has approximately 910 MB.
For faster builds, increase the maximum heap size for the Gradle daemon to more than 2048 MB.
To do this set org.gradle.jvmargs=-Xmx2048M in the project gradle.properties.
For more information see https://docs.gradle.org/current/userguide/build_environment.html
:mergeDebugJniLibFolders UP-TO-DATE
:transformNative_libsWithMergeJniLibsForDebug
:processDebugJavaRes UP-TO-DATE
:transformResourcesWithMergeJavaResForDebug
:validateDebugSigning
:packageDebug
:zipalignDebug
:assembleDebug
:cdvBuildDebug
BUILD SUCCESSFUL
Total time: 3 mins 44.991 secs
Built the following apk(s):
(...)
So the problem that may prevent a successful build may be another one...
In WINDOW'S open the gradle.properties from ~\Users\UserName\.gradle as shown below: for more info enter link description here
and make sure to set its value to minimum to 4608M as shown below for faster builds org.gradle.jvmargs=-Xmx4608M
Once you do that then you can see the day and night difference in speed building your app...
I'm pretty sure javaMaxHeapSize
and org.gradle.jvmargs
are mutually exclusive.
javaMaxHeapSize
is the old way of doing it, with dex run outside of the process. This will be an argument to the dex process.org.gradle.jvmargs
is the new way of doing it, with dex inside the gradle process. This is the max memory for the whole process (gradle, including dex)
What the warning says is that org.gradle.jvmargs
should be >= javaMaxHeapSize (what you used previously for dex)
+ 512M (an estimation of what's needed for gradle own needs)
.
So if you want to use dex in process (which is faster), you shouldn't care about javaMaxHeapSize
. Just set org.gradle.jvmargs
to a correct value for your project/machine.
There appears to be a bug:
https://code.google.com/p/android/issues/detail?id=208214
Using com.android.tools.build:gradle:2.1.2
I set org.gradle.jvmargs=-Xmx3415M
with dexOptions.javaMaxHeapSize "2g"
and the error message went away.
- Please check at first gradle.propertises at your project root directory.
If it is absence, please create a file as like this , then add org.gradle.jvmargs=-Xmx1536m
otherwise if already there , please increase the size.
I have faced same problem , where i have solved by this way.
Example, in gradle.properties
of your project root.
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m
Try this
defaultConfig {
...
// Enabling multidex support.
multiDexEnabled true
}
'program tip' 카테고리의 다른 글
JBoss AS 7 : tmp를 정리하는 방법? (0) | 2020.10.24 |
---|---|
CALayer IOS의 자동 레이아웃 제약 (0) | 2020.10.24 |
__getitem__ 메서드 이해 (0) | 2020.10.24 |
왜 rake db : migrate : reset이 rake -T에 나열되지 않습니까? (0) | 2020.10.23 |
Docker-죽은 컨테이너를 제거 할 수 없음 (0) | 2020.10.23 |