在Android Studio中启用R8 Shrinker时,超出了GC开销限制 [英] GC overhead limit exceeded when enable R8 Shrinker in Android Studio

查看:168
本文介绍了在Android Studio中启用R8 Shrinker时,超出了GC开销限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Android Studio 3.4(金丝雀9),当我构建我的应用程序时,它失败并出现以下错误

I'm using Android Studio 3.4 (Canary 9), when I build my app, it failed with the following error

任务:app:transformClassesAndResourcesWithR8ForDebug

Task :app:transformClassesAndResourcesWithR8ForDebug

R8是实验功能.如果您遇到任何问题,请提交错误在 https://issuetracker.google.com 上,使用收缩器(R8)"作为组件姓名.您可以通过使用以下命令更新gradle.properties来禁用R8:'android.enableR8 = false'.

R8 is an experimental feature. If you experience any issues, please file a bug at https://issuetracker.google.com, using 'Shrinker (R8)' as component name. You can disable R8 by updating gradle.properties with 'android.enableR8=false'.

AGPBI:{种类":警告",文本":缺少类别:java.lang.instrument.ClassFileTransformer,"源:[{}],"工具:" D8}

AGPBI: {"kind":"warning","text":"Missing class: java.lang.instrument.ClassFileTransformer","sources":[{}],"tool":"D8"}

任务:app:transformClassesAndResourcesWithR8ForDebug失败

Task :app:transformClassesAndResourcesWithR8ForDebug FAILED

失败:构建失败,并出现异常.

FAILURE: Build failed with an exception.

  • 出了什么问题:任务':app:transformClassesAndResourcesWithR8ForDebug'的执行失败.

超出了GC开销限制

当我通过将 android.enableR8 = false 放入 gradle.properties 来禁用R8时.一切正常.

When I disable R8 by putting android.enableR8=false into gradle.properties. Everything is working fine.

那么如何在不禁用R8 Shrinker的情况下解决此错误?因为我真的很想测试R8的功能.

So how can I fix this error without disable R8 Shrinker? Because I'm really want to test functionality of R8.

推荐答案

正如您所说的,您没有使用任何自定义的 JVM args ,请尝试一下.

As you said you are not using any custom JVM args, try it out.

在您的 gradle.properties 文件中,尝试内存设置.例如,尝试设置

In your gradle.properties file try several values for memory settings. For example try to set

org.gradle.jvmargs=-Xmx4096m

如评论部分所建议:

指定用于守护进程的JVM参数.

Specifies the JVM arguments used for the daemon process.

该设置对于调整内存设置特别有用.

The setting is particularly useful for tweaking memory settings.

org.gradle.jvmargs = -Xmx1536m

org.gradle.jvmargs=-Xmx1536m

我在项目中使用了R8,并且一切正常.

I've used R8 in my project and all worked fine.

这篇关于在Android Studio中启用R8 Shrinker时,超出了GC开销限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆