react-native打包图片资源的大坑啊

react

error: uncompiled PNG file passed as argument. Must be compiled first into .flat file..

error: failed parsing overlays.

解决方法:在gradle.properties文件中添加以下行:android.enableAapt2 = false,它实质上使用旧的aapt来获取资源。

然后又出现了下面

/xxx/android/app/build/intermediates/res/merged/dev/release/drawable-hdpi-v4/node_modules_reactnavigation_src_views_assets_backicon.png: error: Duplicate file.

/xxx/android/app/build/intermediates/res/merged/dev/release/drawable-hdpi/node_modules_reactnavigation_src_views_assets_backicon.png: Original is here. The version qualifier may be implied.

:app:processDevReleaseResources FAILED

FAILURE: Build failed with an exception.

What went wrong:

Execution failed for task ‘:app:processDevReleaseResources’.

解决方法:

把:node_modules/react-native/local-cli/bundle/assetPathUtils.js这个文件里面getAndroidAssetSuffix方法改为

function getAndroidAssetSuffix(scale) {

switch (scale) {

case 0.75: return 'ldpi-v4';

case 1: return 'mdpi-v4';

case 1.5: return 'hdpi-v4';

case 2: return 'xhdpi-v4';

case 3: return 'xxhdpi-v4';

case 4: return 'xxxhdpi-v4';

}

}

_(:з」∠)_都是坑头发都掉。

以上是 react-native打包图片资源的大坑啊 的全部内容, 来源链接: utcz.com/z/384332.html

回到顶部