Android Studio导入项目运行出现大量警告,且报错GC,解决办法

问题描述:

同事给了一个项目让我运行,我打开工程后,本地使用的gradle 3.3版本和com.android.tools.builld:gradle:2.3.2版本都要高于项目本身指定的gradle 2.14.1和2.2.3,使用本地自己的版本没有去下载项目原来指定的版本,build项目没有问题,运行项目,发现运行时间很久,半天都没动静,运行结束发现报错了。

错误如下:

1.Warning:warning: Ignoring InnerClasses attribute for an anonymous inner class
(com.tencent.mm.sdk.openapi) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.

大量的这种警告,大概意思就是使用的jar版本太老,需要使用新版本,

不过这个是警告,你不去处理也不会影响项目运行,所以虽然很多,但是别慌,可以不用理他。

2.Error:UNEXPECTED TOP-LEVEL ERROR:
Error:java.lang.OutOfMemoryError: GC overhead limit exceeded
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Error while executing java process with main class……

这个错误才是项目运行不起来的真正原因,其实也很简单解决,第一行是不是看不懂?但是没关系我看得懂第二行,GC了,所以从看得懂的地方入手,先解决GC,打开你项目中的gradle.properties文件,在文件里增加一行

org.gradle.jvmargs=-Xmx2048m

这个配置就好了,系统默认的大小是1024,我们增大就行了。

备注:其实最简单的方法还是去下载项目指定的gradle版本和com.android.tools.builld:gradle版本,这样基本都不会出现什么问题,但是谁让我们可能网不好呢,唉。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值