運行在手機上沒問題,但是打包的時候報錯如下:
uncompiled PNG file passed as argument. Must be compiled first into .flat file..
網上搜索了答案:
繼續執行我們的打包命令,但是又報了其他錯誤:
Duplicate file. /Users/user/Demo/app/XXX/android/app/build/intermediates/res/merged/release/drawable-hdpi/node_modules_reactnavigation_src_views_assets_backicon.png: Original is here. The version qualifier may be implied.
解決方法:
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';
}
}
在項目根目錄下執行:
cd android
./gradlew clean
在執行打包命令
打包成功