Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

9 patch image prevent build project android studio

I am moving to Gradle build . but i have this error for a lot of 9-patch images .

Note the drawable is auto generated by http://android-holo-colors.com but they are old.

I am using android studio 0.5.1 and my build tool version is 19.0.3 this is the error

Error:Execution failed for task ':app:mergeDebugResources'.
> Error: Failed to run command:
    /Applications/Android Studio.app/sdk/build-tools/19.0.3/aapt s -i /Users/Ed/Desktop/TestAndroid/app/src/main/res/drawable-mdpi/spinner_default_holo_dark.9.png -o /Users/Ed/Desktop/TestAndroid/app/build/res/all/debug/drawable-mdpi/spinner_default_holo_dark.9.png
  Error Code:
    42
  Output:
    ERROR: 9-patch image /Users/Ed/Desktop/TestAndroid/app/src/main/res/drawable-mdpi/spinner_default_holo_dark.9.png malformed.
           Frame pixels must be either solid or transparent (not intermediate alphas).
           Found at pixel #3 along top edge.
    /Users/Ed/Desktop/TestAndroid/app/src/main/res/drawable-hdpi/cab_background_bottom_test.9.png
    Error:Ticks in transparent frame must be black or red. - ERROR: 9-patch image /Users/Ed/Desktop/TestAndroid/app/src/main/res/drawable-mdpi/spinner_default_holo_dark.9.png malformed.

Anyone faced the same problem.

like image 458
user4o01 Avatar asked Mar 10 '14 19:03

user4o01


People also ask

What is the use of 9 patch image in android?

The Draw 9-patch tool is a WYSIWYG editor included in Android Studio 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 on indicators drawn within the image.

What is a 9 PNG file?

A 9 patch image is a regular png (. PNG) image which is needful for android app developers where they require to wrap any content within a background image without pixelating the background image.

Why does Android studio take so long?

According to Android Studio's official system requirements, it takes at minimum 3 GB RAM to run smoothly. Honestly, its a lot and I believe that is the biggest cause of being it too slow all the time.

What is a 9 patch?

What is a 9-patch image? Essentially, a 9-patch image is a custom graphic that scales the way that you intend it to, which you define when creating the graphic. Where supported, this stretchable image is automatically resized to accommodate the content as defined.


1 Answers

Have you tried following the suggestions in the error log? I.e. take a look at the 3rd (possibly 4th if it treats it as zero indexed?) Pixel along the top row in an image editor:

  • Is the pixel red or black (#FF0000 or #000000)?
  • Does it have an alpha value of 255 or 0?

If the answer is "no", then I guess that's your problem. This will then obviously also need to be applied to all other marker pixels around the edge of the images.

I'd add this as a comment, but don't have enough rep - sorry.

like image 135
Jasongiss Avatar answered Sep 26 '22 00:09

Jasongiss