xfshipan xfshipan - 4 months ago 41
Android Question

android studio build .9.png format error

This is the error log:

Error:Execution failed for task ':MobileSafe2:mergeDebugResources'.
Crunching Cruncher call_locate_blue.9.png failed, see logs

But when I turn the
extension into
, the error will disappear, I don't know why it happens.

This is the code :

public void myToast(String address) {
View view = View.inflate(context, R.layout.address_show, null);

TextView textView = (TextView) view.findViewById(R.id.tv_address);

WindowManager.LayoutParams params = new WindowManager.LayoutParams();

params.height = WindowManager.LayoutParams.WRAP_CONTENT;
params.width = WindowManager.LayoutParams.WRAP_CONTENT;

params.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
| WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
| WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
params.format = PixelFormat.TRANSLUCENT;
params.type = WindowManager.LayoutParams.TYPE_TOAST;
wm.addView(view, params);

This is in Android Studio enter image description here

The error infomation:
enter image description here

I have got to fix '.9.png' into '.png', then it can work, but the picture will be distorted


As far as I can see, you didn't put the 9 patch markers.
These ones are needed to turn a png into a 9.png (properly said a 9 patch).

Without those markers, it will be a normal image - but the IDE expects something else, because the extension tells "Hey, I'm a 9 patch: treat me properly".

So to speak, it's like if you buy a lemonade, but you find an apple juice inside.

Here you'll find a nice tutorial on 9 patches: http://blog.booleanbites.com/2012/11/android-how-to-use-9-patch-png.html