【问题集】点9图(9-patch image)导致的"No resource found"

来源:互联网 发布:java 什么是异常 编辑:程序博客网 时间:2024/06/13 13:59

错误现象:

默认打包都没问题.而且都可以运行.而用 ant的build.xml文件进行打包编译时出现以下错误:


error: Error: No resource found that matches the given name (at 'drawable' with value '@drawable/xxx').

分析:

一般是因为你的项目中的图片出了问题,最有可能的就是9-patch image出现问题,导致ant解析不了。

看LOG你会找到如下描述:
ERROR: 9-patch image ****.9.png malformed.
或 No marked region found along edge.
以及 Found along top edge.的错误
主要是因为该图片没有四周的定位像素。
至少必须在左边和上方定位像素。

解决方案:

  1. 检测点9图的边上是否有1px的边距(目测没有)
  2. 找到原图重新切图,让原图的边上加上1px的空白(用来拉伸)。
  3. 将新的有边距的图,切点9.
  4. 替换工程中对应点9图。在运行,错误应该就解决了。
0 0