简体   繁体   中英

9patch image and Android Studio build failing

I have an interesting issue, and I dont know how to handle it. So, until now everything was fine, I was able to build my project. I just replaced an image with it`s 9patch version in three different sizes(mdpi, hdpi, xhdpi).

tw.setBackgroundResource(R.drawable.tag_rotate)

This is the line, where the building failing. It`s interesing, because the studio is able to show me the image on the left, and it is NOT marked as red. But the build is failing with the following message:

Error:(196, 52) error: cannot find symbol variable tag_rotate

UPDATE: if I remove the image from the code, and replace with a normal image, it works ! Im using the default 9patcher provided by SDK

What kind of nine-patch generator do you use? I recomend you to use this generator. I tried to use standart android 9patch generator, which delivered with android SDK, and I had the problems with it.

Check if there is a line on your imports that says import android.R; .

If there is,Delete the import and it should be fine.

The Draw 9-patch tool is a WYSIWYG editor that allows you to create bitmap images that automatically resize to accommodate the contents of the view and the size of the screen. Selected parts of the image are scaled horizontally or vertically based indicators drawn within the image.

http://developer.android.com/tools/help/draw9patch.html

Nine-patch generator

https://android-ui-utils.googlecode.com/hg-history/9472134d092f3375aa9cf767d6a4b2eca561c0ba/asset-studio/dist/nine-patches.html

如果您使用在线生成器工具,请不要使用任何特殊字符作为图像名称

The 9 patch tool in android studio is automatically generating bad patches. You need to repatch till the red bad patches go away and the error should be fixed. To see bad patches just select the Show bad patches checkbox.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM