React-Native 踩坑记录

在React-Native开发的过程中,遇到了非常多的问题,好在社区比较强大,搜索都解决了。这里做一个记录,一个是自己做备忘,防止哪天又碰到相同问题;另一个,也给其他碰到的人做一个总结。

  1. gradle 3.3 在windows下报apt打包错误
    解决方案:升级到3.4
  2. build出现:Error:Execution failed for task ‘:app:transformClassesWithDexForDebug’. > java.lang.OutOfMemoryError: GC overhead limit exceeded
    解决方案:
    次点击 Help > Edit Custom VM Options 以打开 studio.vmoptions 文件。(没有新建就行)
    之后编辑文件,填入配置,然后保存,重启Android studio

    -Xms256m
    -Xmx3080m
    -XX:MaxPermSize=350m
    -XX:ReservedCodeCacheSize=225m
    -XX:+UseCompressedOops

  3. 升级到gradle5之后,build release报错unable to load script make sure you are either running a metro server or that your bundle “index.android.bundle” is packaged correctly for release https://github.com/facebook/react-native/issues/25348
    解决方案:
    build release之前运行:
    react-native bundle –platform android –dev false –entry-file index.js –bundle-output android/app/src/main/assets/index.android.bundle –assets-dest android/app/src/main/res
  4. 接问题3,运行bundle之后,build release出现报错:Duplicate resources
    解决方案:
    https://github.com/facebook/react-native/issues/19239#issuecomment-414564404
    android-> app -> src -> main -> res文件夹里,除了drawable,其他drawable-hdpi之类的,都删除即可

发表评论

电子邮件地址不会被公开。 必填项已用*标注