react-native 0.58版本打包图片问题 task ':app:mergeReleaseResources' Error: Duplicate resources...

本文介绍了一种在使用React Native构建正式APK时遇到的资源文件处理问题,并提供了详细的解决方案。通过修改react.gradle文件中的特定代码段,可以确保不同分辨率的资源文件正确地从构建目录移动到主项目目录。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

debug没问题,在生成正式apk的时候就如下:

google了一下在github上找到了解决方案:

github问题指向

在node_modules/react-native/react.gradle   

修改为

 

doLast {
    def moveFunc = { resSuffix ->
        File originalDir = file("$buildDir/generated/res/react/release/drawable-${resSuffix}");
        if (originalDir.exists()) {
            File destDir = file("$buildDir/../src/main/res/drawable-${resSuffix}");
            ant.move(file: originalDir, tofile: destDir);
        }
    }
    moveFunc.curry("ldpi").call()
    moveFunc.curry("mdpi").call()
    moveFunc.curry("hdpi").call()
    moveFunc.curry("xhdpi").call()
    moveFunc.curry("xxhdpi").call()
    moveFunc.curry("xxxhdpi").call()
}

 

转载于:https://www.cnblogs.com/pengkun06Gmail/p/10373761.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值