今天做一个东西的时候,用PS做了几个图片,但是更改了后缀,于是出现了错误:
错误描述:
一开始是eclipse上的项目处出现错误,但是找文件夹里却没有一点错误,但在控制带确输出了大量的如下的红色错误信息
[2011-05-26 12:44:51 - ImageViewTest] libpng error: Not a PNG file
[2011-05-26 12:44:51 - ImageViewTest] ERROR: Failure processing PNG image E:\lOVEAndroid\workspace\ImageViewTest\res\drawable\img01.png
[2011-05-26 12:44:51 - ImageViewTest] E:\lOVEAndroid\workspace\ImageViewTest\res\layout\main.xml:7: error: Error: No resource found that matches the given name (at 'src' with value '@drawable/img01').
当时不知道怎么回事,找来找去就是找不到错误的原因,后来看了一下文件的错误,说是不是png文件,好吧,于是把里面的所有其他格式的图片都在eclipse里面改成了png,但是最终修改数量的增加,错误数量也不断的增加,后来问了一些大牛,又在网上查了一下,才知道,原来是更改文件后缀的问题,如果你是直接在eclipse里更改文件后缀,或者是在桌面上自己更改后缀,那么这个问题就出来了,但是如果你用画图工具,比如PS等把图片改成某一种格式,比如png,jpeg等,再放到drawable里,就不会出现错误
为了验证是不是这样,于是我做了个测试
此时,这个文件名字的后缀是gif的,于是Refactor--Rename
点击确定后,观察控制台,打印了如下的错误信息
[2011-05-26 12:44:51 - ImageViewTest] libpng error: Not a PNG file
[2011-05-26 12:44:51 - ImageViewTest] ERROR: Failure processing PNG image E:\lOVEAndroid\workspace\ImageViewTest\res\drawable\img01.png
[2011-05-26 12:44:51 - ImageViewTest] E:\lOVEAndroid\workspace\ImageViewTest\res\layout\main.xml:7: error: Error: No resource found that matches the given name (at 'src' with value '@drawable/img01').
证明刚才的那个假设是正确的
那么会有人问,是不是只有在eclipse上更改图片后缀会出现这个问题呢,答案:不是
即使你在自己的桌面上更改一张图片的后缀,然后拷贝到drawable文件夹下,错误依然会出现
test.jpg可以正常使用,当你在桌面上更改其后缀为png以后,结果依然是那样
注意:我试验了几次,gif格式的文件没问题,就是png文件更改成其他格式的文件,或者其他格式的文件更改成png格式的文件会出现这个问题
解决办法就是用原来的文件名,或者如果自己更改文件出现了这个问题时候,就可能是这个原因
另外还有一个错误要提出来,就是drawable里文件的命名问题,目前只能是用用小写字母和数字命名图片文件
比如拷贝一个Moon.jpg文件到drawable文件夹后,就会出现如下的错误
[2011-05-26 13:11:13 - ImageViewTest] res\drawable\Moon.jpg: Invalid file name: must contain only [a-z0-9_.]
[2011-05-26 13:11:13 - ImageViewTest] E:\lOVEAndroid\workspace\ImageViewTest\res\layout\main.xml:7: error: Error: No resource found that matches the given name (at 'src' with value '@drawable/img01').
这些问题,以后注意要注意
- 大小: 3.9 KB
- 大小: 6.8 KB
分享到:
相关推荐
android-gif-drawable 用于在Android上显示动画GIF
android-gif-drawable Views and Drawable for animated GIFs in Android. Overview Bundled GIFLib via JNI is used to render frames. This way should be more efficient than WebView or Movie classes. ...
Android-android-gif-drawable.zip,在android上显示动画gif的视图和绘图,安卓系统是谷歌在2008年设计和制造的。操作系统主要写在爪哇,C和C 的核心组件。它是在linux内核之上构建的,具有安全性优势。
参照github上android-gif-drawable框架出现的5.0不适配的问题。
SVG -> drawable-xhdpi、drawable-hdpi、drawable-mdpi、drawable-ldpi Android SVG 资源生成器 未来证明您的资产并节省时间! 创建/查找一次,不用担心 DPI 存储桶。 此工具允许您将 SVG 文件用于您的 Android ...
android-gif-drawable 开源组件,需要的朋友下载
android-gif-drawable支持fig显示的view.zip
开源库 android-gif-drawable使用的jar包,使用详见博客http://blog.csdn.net/u012587637/article/details/18596465
github最新android-gif-drawable资源so; android-async-http-1.4.5.jar demo中实现了本地gif显示和网络加载gif显示
Drawable Badge一个用于向Drawable添加徽章的Android库
Android应用源码之android-gif-drawable 支持fig显示的view.zip
EditDrawableText - An EditText which makes your Drawable Clickable.zip,EditDrawableText - An EditText which makes your Drawable Clickable
【Android开发API】应用程序资源-图形处理类资源-Drawable[参照].pdf
android-gif-drawable最快最流畅的GIF,带源码带so库,带范例!不像很多其他资源,虽说用了android-gif-drawable的开源项目,但是没有编译so,也没有上传,你下载他的根本用不了!因此特意上传亲测可以直接使用的给...
Android高级应用源码-android-gif-drawable 支持fig显示的view.zip
TextViewRichDrawable This is a tiny library which empowers TextView's (and its inheritors) compound drawables with size specifying, vector support and tinting...Enable vector Drawable support for pre Lo
Android Drawable Importer Plugin This plugin consists of three main features. You can access them by right-clicking anywhere, but not on a file, inside an Android (library) module under New. ...
几种比较流行的图片加载框架,可以播放gif格式的动态图片,它们分别是 glide-3.7.0.jar picasso-2.5.2.jar android-gif-drawable-master.jar。
Android drawable preview plugin Android studio and IntelliJ IDEA plugin that replaces default icons with drawables previews inside project view. Installation Download plugin zip archive Inside ...
android-gif-drawable 支持fig显示的view.zip,太多无法一一验证是否可用,程序如果跑不起来需要自调,部分代码功能进行参考学习。