我正在使用此命令构建应用程序以进行发布: ./ gradlew assembleRelease ,但我收到此错误:
uncaught error Error: Don't know which android drawable suffix to use for asset: {"__packager_asset":true,"fileSystemLocation":"/home/marco/Lavoro/react/FarEast/img","httpServerLocation":"/assets/img","width":140,"height":83,"scales":[1,2,3,4,5],"files":["/home/marco/Lavoro/react/FarEast/img/main_halfcard_upper@1x.png","/home/marco/Lavoro/react/FarEast/img/main_halfcard_upper@2x.png","/home/marco/Lavoro/react/FarEast/img/main_halfcard_upper@3x.png","/home/marco/Lavoro/react/FarEast/img/main_halfcard_upper@4x.png","/home/marco/Lavoro/react/FarEast/img/main_halfcard_upper@5x.png"],"hash":"1d3f184ba6cf0e73bee648bb6b5aea53","name":"main_halfcard_upper","type":"png"}
at Object.getAndroidDrawableFolderName (assetPathUtils.js:25:11)
at getAssetDestPathAndroid (getAssetDestPathAndroid.js:15:40)
at saveAssets.js:38:44
at Array.forEach (native)
at saveAssets.js:36:20
at Array.forEach (native)
at saveAssets (saveAssets.js:35:6)
at buildBundle.js:65:29
at tryCallOne (/home/marco/Lavoro/react/FarEast/node_modules/react-native/node_modules/promise/lib/core.js:37:12)
at /home/marco/Lavoro/react/FarEast/node_modules/react-native/node_modules/promise/lib/core.js:123:15
:app:bundleReleaseJsAndAssets FAILED
我该如何解决这个问题?
答案 0 :(得分:3)
显然我使用错误的标签来指示图像的大小。
这是正确的方法(取自 assetPathUtils.js )
case 0.75: return 'ldpi';
case 1: return 'mdpi';
case 1.5: return 'hdpi';
case 2: return 'xhdpi';
case 3: return 'xxhdpi';
case 4: return 'xxxhdpi';
所以 image@1.5x.png 与原生 ldpi 相匹配, image@1x.png 匹配原生 mdpi 等。
答案 1 :(得分:3)
我使用ldpi手机(模拟器)得到以下类似错误,但在我的./img
文件夹中没有./img/green-apple@0.75.png
图片:
uncaught error Error: Don't know which android drawable suffix to use for asset: {"__packager_asset":true,"fileSystemLocation":"/Users/vasavi/dev/prashanthWorkspace/dev/img","httpServerLocation":"/assets/img","width":34,"height":38,"scales":[0.5,1,1.5,2,3],"files":["/Users/vasavi/dev/prashanthWorkspace/dev/img/green-apple@0.5x.png","/Users/vasavi/dev/prashanthWorkspace/dev/img/green-apple@1x.png","/Users/vasavi/dev/prashanthWorkspace/dev/img/green-apple@1.5x.png","/Users/vasavi/dev/prashanthWorkspace/dev/img/green-apple@2x.png","/Users/vasavi/dev/prashanthWorkspace/dev/img/green-apple@3x.png"],"hash":"f017f83c41b557cf3c65663d7f4f0583","name":"green-apple","type":"png"}
at Object.getAndroidDrawableFolderName (assetPathUtils.js:25:11)
at getAssetDestPathAndroid (getAssetDestPathAndroid.js:15:40)
at saveAssets.js:38:44
at Array.forEach (native)
at saveAssets.js:36:20
at Array.forEach (native)
at saveAssets (saveAssets.js:35:6)
at buildBundle.js:72:29
at tryCallOne (/Users/vasavi/dev/prashanthWorkspace/dev/node_modules/promise/lib/core.js:37:12)
at /Users/vasavi/dev/prashanthWorkspace/dev/node_modules/promise/lib/core.js:123:15
:app:bundleReleaseJsAndAssets FAILED
解决方案是:如果您正在使用
./img/green-apple@0.75.png
或./img/green-apple@1.png
或./img/green-apple@1.5.png
或./img/green-apple@2.png
或./img/green-apple@3.png
或./img/green-apple@4.png
。