Marco Fedele Marco Fedele - 4 months ago 47
Android Question

Rect-Native drawable error when building the Android app

I'm building the app for release using this command: ./gradlew assembleRelease, but I'm getting this error:

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


How can I solve this?

Answer

Apparently I was using the wrong tag to indicate the sizes of the images.

This is the correct approach (taken from 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';

So image@1.5x.png matches native ldpi, image@1x.png matches native mdpi and so on.

Comments