android studio构建。9。png格式错误

时间:2021-07-27 20:50:49

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 .9.png extension into .png, the error will disappear, I don't know why it happens.

但是当我转到。9的时候。png扩展到。png,错误就会消失,我不知道为什么会发生。

This is the code :

这是代码:

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

        TextView textView = (TextView) view.findViewById(R.id.tv_address);
        textView.setText(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 android studio构建。9。png格式错误

这是Android Studio

The error infomation: android studio构建。9。png格式错误

错误信息:

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

我得修理一下。png“成”。png,然后它可以工作,但是图像会被扭曲。

4 个解决方案

#1


5  

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).

据我所知,你没有放9个补丁标记。这些是把png变成9所需要的。png(正确地说是9个补丁)。

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".

如果没有这些标记,这将是一个正常的图像——但是IDE需要其他东西,因为扩展告诉“嘿,我是一个9补丁:正确对待我”。

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

在这里,您将看到9个补丁的精彩教程:http://blog.booleanbites.com/2012/11/android-how to use-9 patch-png.html

#2


0  

You can just do a little editing on the .9.png image file so that Android Studio can recognize that it is a 9 patch file . I just do it like above and it works for me .

你可以对。9进行一些编辑。png图像文件,使Android Studio可以识别它是一个9补丁文件。我只是像上面那样做,它对我很有效。

#3


0  

I had the same problem. I had to first open the image in Android Studio and set the bounds of the image to be stretched. There needs to be a line on the edge of the image telling it how to be stretched. In Android studio they made this easy to adjust. If you click the show content box, You can see how your image is going to be stretched. For me this was SUPER useful in making chat bubbles.

我也有同样的问题。我必须首先打开Android Studio中的图像,并设置图像的边界。图像边缘需要有一条线告诉它如何拉伸。在Android studio中,他们可以很容易地进行调整。如果单击“显示内容”框,可以看到图像将如何展开。对我来说,这在聊天泡泡中非常有用。

#4


0  

Try refactoring the file and rename to filename.9.png

尝试重构文件并重命名为filename.9.png。

#1


5  

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).

据我所知,你没有放9个补丁标记。这些是把png变成9所需要的。png(正确地说是9个补丁)。

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".

如果没有这些标记,这将是一个正常的图像——但是IDE需要其他东西,因为扩展告诉“嘿,我是一个9补丁:正确对待我”。

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

在这里,您将看到9个补丁的精彩教程:http://blog.booleanbites.com/2012/11/android-how to use-9 patch-png.html

#2


0  

You can just do a little editing on the .9.png image file so that Android Studio can recognize that it is a 9 patch file . I just do it like above and it works for me .

你可以对。9进行一些编辑。png图像文件,使Android Studio可以识别它是一个9补丁文件。我只是像上面那样做,它对我很有效。

#3


0  

I had the same problem. I had to first open the image in Android Studio and set the bounds of the image to be stretched. There needs to be a line on the edge of the image telling it how to be stretched. In Android studio they made this easy to adjust. If you click the show content box, You can see how your image is going to be stretched. For me this was SUPER useful in making chat bubbles.

我也有同样的问题。我必须首先打开Android Studio中的图像,并设置图像的边界。图像边缘需要有一条线告诉它如何拉伸。在Android studio中,他们可以很容易地进行调整。如果单击“显示内容”框,可以看到图像将如何展开。对我来说,这在聊天泡泡中非常有用。

#4


0  

Try refactoring the file and rename to filename.9.png

尝试重构文件并重命名为filename.9.png。