开发笔记2012-11-22

        本周将Eclipse中测试通过的几个项目,移到源码平台下(ubuntu)进行编译,一堆的错误,令人纠结。现将其总结下。


问题一:资源文件名冲突

        资源文件中存在着名称相同格式不同的两幅图片(比如image.jpg和image.png同时存在于资源文件中)会导致编译出错。原因在于系统在编译时只是根据图片的名称来生成相应的资源ID,而忽略其后缀。两个图像资源对应着同一个ID,出错是不可避免的。


问题二:点九图片引发的血案

        代码移到平台下编译,holy crap!满屏的error,不过还好,仔细看了下,发现问题所在:所有的图片资源全都找不到。查看过日志后,发现错误的根源集中在drawable-hdpi下若干个点九图片上(什么是点九图片?百度去吧。。。),于是,尝试着将这几个图片更改为非点九的图片的名称,编译通过!然而,生成的APK包无法使用,单看APK文件的大小就感觉不妙--比eclipse下编译出来的小1M多。打开apk包才发现,其资源文件中只存在drawable-hdpi目录,而drawable-ldpi和drawable-mdpi不存在,换句话说:这两个资源包未被打包进最终的apk中,于是,就有了问题三。


问题三:对drawable-*dpi编译的控制

        如何将三个图片资源目录全部编译,对于这个问题,解决方法也很简单,在文件build/target/product/generic.mk中加入如下代码:

        CUSTOM_LOCALES:= hdpi ldpi mdpi

        OK,问题解决。继续编译,出错,查看日志发现出错的原因在于drawable-mdpi目录下依然存在着一幅以点九图片方式命名的非点九图片,修改后终于编译成功。

        参考:http://blog.sina.com.cn/s/blog_477daa680100jngd.html

        http://lostghoul.blog.163.com/blog/static/11172199920112842738688/


问题四:代码混淆问题

        编译过程中,出现N多的warning,之后跟着如下的log,

Note: there were 1 unresolved dynamic references to classes or interfaces.
      You should check if you need to specify additional program jars.
Note: there were 1 class casts of dynamically created class instances.
      You might consider explicitly keeping the mentioned classes and/or
      their implementations (using '-keep').
Note: there were 2 accesses to class members by means of introspection.
      You should consider explicitly keeping the mentioned class members
      (using '-keep' or '-keepclassmembers').
Warning: there were 3 unresolved references to classes or interfaces.
         You may need to specify additional library jars (using '-libraryjars'),
         or perhaps the '-dontskipnonpubliclibraryclasses' option.
Warning: there were 75 instances of library classes depending on program classes.
         You must avoid such dependencies, since the program classes will
         be processed, while the library classes will remain unchanged.
Warning: there were 23 unresolved references to program class members.
         Your input classes appear to be inconsistent.
         You may need to recompile them and try again.
         Alternatively, you may have to specify the options 
         '-dontskipnonpubliclibraryclasses' and/or
         '-dontskipnonpubliclibraryclassmembers'.
Error: Please correct the above warnings first.
make: *** [out/target/common/obj/APPS/EtonBbs_intermediates/proguard.classes.jar] 错误 
make:离开目录“/home/ldk/ldk_Code/TD/d525_shenzheng_svn”

        解决方法:在Android.mk文件中添加如下代码

                LOCAL_PROGUARD_ENABLED := disabled

         此代码的功能是关闭代码混淆, 如此即可编译成功。  

        参考:http://blog.csdn.net/evilcode/article/details/6860182 

 

问题五:touch

        现象:strings.xml明明存在某个变量的定义,或是drawable-*dpi里明明存在某个资源图片,但编译时总是提示此资源无定义

        建议:touch下出错资源文件,说不定会有意想不到的效果。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值