Android 关于图片文件夹后缀错误,使应用在源码下编译通过却无法运行的错误
2012-07-18 16:31 Terry_龙 阅读(5632) 评论(3) 编辑 收藏 举报问题描述:
同事在处理一个应用,之前一直在Eclipse 下编译,并运行到开发板上调试,一切正常,相安无事。
后来需要在源码下编编译使一些动态库取得系统权限,源码下编译也是很顺利的,但一跑到开发板上就出错无法运行,直接force stop.
相关出错的Logcat :
E/AndroidRuntime( 1969): FATAL EXCEPTION: main
E/AndroidRuntime( 1969): java.lang.RuntimeException: Unable to start activity ComponentInfo{
com.android.xuzhitech.xfree/com.android.xuzhitech.xfree.ui.XFreeMain}: java.lang.RuntimeException: Unabl>
E/AndroidRuntime( 1969): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
E/AndroidRuntime( 1969): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
E/AndroidRuntime( 1969): at android.app.ActivityThread.access$600(ActivityThread.java:123)
E/AndroidRuntime( 1969): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
E/AndroidRuntime( 1969): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 1969): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime( 1969): at android.app.ActivityThread.main(ActivityThread.java:4424)
E/AndroidRuntime( 1969): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 1969): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime( 1969): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
E/AndroidRuntime( 1969): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
E/AndroidRuntime( 1969): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 1969): Caused by: java.lang.RuntimeException: Unable to start activity ComponentInfo{
com.android.xuzhitech.xfree/com.android.xuzhitech.xfree.ui.LocalComputerActivity}: android.vi>
E/AndroidRuntime( 1969): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
E/AndroidRuntime( 1969): at android.app.ActivityThread.startActivityNow(ActivityThread.java:1797)
E/AndroidRuntime( 1969): at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:135)
E/AndroidRuntime( 1969): at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:347)
E/AndroidRuntime( 1969): at com.android.xuzhitech.utils.Utils.getView(Utils.java:54)
E/AndroidRuntime( 1969): at com.android.xuzhitech.xfree.ui.XFreeMain.InitViewPager(XFreeMain.java:83)
E/AndroidRuntime( 1969): at com.android.xuzhitech.xfree.ui.XFreeMain.onCreate(XFreeMain.java:58)
E/AndroidRuntime( 1969): at android.app.Activity.performCreate(Activity.java:4465)
E/AndroidRuntime( 1969): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
E/AndroidRuntime( 1969): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
E/AndroidRuntime( 1969): ... 11 more
E/AndroidRuntime( 1969): Caused by: android.view.InflateException: Binary XML file line #9: Error inflating class <unknown>
E/AndroidRuntime( 1969): at android.view.LayoutInflater.createView(LayoutInflater.java:606)
E/AndroidRuntime( 1969): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
E/AndroidRuntime( 1969): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:653)
E/AndroidRuntime( 1969): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678)
E/AndroidRuntime( 1969): at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
E/AndroidRuntime( 1969): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
E/AndroidRuntime( 1969): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
E/AndroidRuntime( 1969): at com.android.xuzhitech.xfree.ui.LocalComputerFirstLayout.onCreateView(LocalComputerFirstLayout.java:33)
E/AndroidRuntime( 1969): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:828)
E/AndroidRuntime( 1969): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1032)
E/AndroidRuntime( 1969): at android.app.BackStackRecord.run(BackStackRecord.java:622)
E/AndroidRuntime( 1969): at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1382)
E/AndroidRuntime( 1969): at android.app.Activity.performStart(Activity.java:4474)
E/AndroidRuntime( 1969): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1929)
E/AndroidRuntime( 1969): ... 20 more
E/AndroidRuntime( 1969): Caused by: java.lang.reflect.InvocationTargetException
E/AndroidRuntime( 1969): at java.lang.reflect.Constructor.constructNative(Native Method)
E/AndroidRuntime( 1969): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
E/AndroidRuntime( 1969): at android.view.LayoutInflater.createView(LayoutInflater.java:586)
E/AndroidRuntime( 1969): ... 33 more
E/AndroidRuntime( 1969): Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable
(color or path): TypedValue{t=0x1/d=0x7f020007 a=-1 r=0x7f020007}
E/AndroidRuntime( 1969): at android.content.res.Resources.loadDrawable(Resources.java:1899)
E/AndroidRuntime( 1969): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
E/AndroidRuntime( 1969): at android.view.View.<init>(View.java:2785)
E/AndroidRuntime( 1969): at android.view.ViewGroup.<init>(ViewGroup.java:385)
E/AndroidRuntime( 1969): at android.widget.LinearLayout.<init>(LinearLayout.java:174)
E/AndroidRuntime( 1969): at androi
D/dalvikvm( 1969): GC_CONCURRENT freed 874K, 14% free 6176K/7175K, paused 3ms+2ms
E/AndroidRuntime( 1969): java.lang.RuntimeException: Unable to start activity ComponentInfo{
com.android.xuzhitech.xfree/com.android.xuzhitech.xfree.ui.XFreeMain}: java.lang.RuntimeException: Unabl>
E/AndroidRuntime( 1969): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
E/AndroidRuntime( 1969): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
E/AndroidRuntime( 1969): at android.app.ActivityThread.access$600(ActivityThread.java:123)
E/AndroidRuntime( 1969): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
E/AndroidRuntime( 1969): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 1969): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime( 1969): at android.app.ActivityThread.main(ActivityThread.java:4424)
E/AndroidRuntime( 1969): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 1969): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime( 1969): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
E/AndroidRuntime( 1969): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
E/AndroidRuntime( 1969): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 1969): Caused by: java.lang.RuntimeException: Unable to start activity ComponentInfo{
com.android.xuzhitech.xfree/com.android.xuzhitech.xfree.ui.LocalComputerActivity}: android.vi>
E/AndroidRuntime( 1969): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
E/AndroidRuntime( 1969): at android.app.ActivityThread.startActivityNow(ActivityThread.java:1797)
E/AndroidRuntime( 1969): at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:135)
E/AndroidRuntime( 1969): at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:347)
E/AndroidRuntime( 1969): at com.android.xuzhitech.utils.Utils.getView(Utils.java:54)
E/AndroidRuntime( 1969): at com.android.xuzhitech.xfree.ui.XFreeMain.InitViewPager(XFreeMain.java:83)
E/AndroidRuntime( 1969): at com.android.xuzhitech.xfree.ui.XFreeMain.onCreate(XFreeMain.java:58)
E/AndroidRuntime( 1969): at android.app.Activity.performCreate(Activity.java:4465)
E/AndroidRuntime( 1969): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
E/AndroidRuntime( 1969): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
E/AndroidRuntime( 1969): ... 11 more
E/AndroidRuntime( 1969): Caused by: android.view.InflateException: Binary XML file line #9: Error inflating class <unknown>
E/AndroidRuntime( 1969): at android.view.LayoutInflater.createView(LayoutInflater.java:606)
E/AndroidRuntime( 1969): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
E/AndroidRuntime( 1969): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:653)
E/AndroidRuntime( 1969): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678)
E/AndroidRuntime( 1969): at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
E/AndroidRuntime( 1969): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
E/AndroidRuntime( 1969): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
E/AndroidRuntime( 1969): at com.android.xuzhitech.xfree.ui.LocalComputerFirstLayout.onCreateView(LocalComputerFirstLayout.java:33)
E/AndroidRuntime( 1969): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:828)
E/AndroidRuntime( 1969): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1032)
E/AndroidRuntime( 1969): at android.app.BackStackRecord.run(BackStackRecord.java:622)
E/AndroidRuntime( 1969): at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1382)
E/AndroidRuntime( 1969): at android.app.Activity.performStart(Activity.java:4474)
E/AndroidRuntime( 1969): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1929)
E/AndroidRuntime( 1969): ... 20 more
E/AndroidRuntime( 1969): Caused by: java.lang.reflect.InvocationTargetException
E/AndroidRuntime( 1969): at java.lang.reflect.Constructor.constructNative(Native Method)
E/AndroidRuntime( 1969): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
E/AndroidRuntime( 1969): at android.view.LayoutInflater.createView(LayoutInflater.java:586)
E/AndroidRuntime( 1969): ... 33 more
E/AndroidRuntime( 1969): Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable
(color or path): TypedValue{t=0x1/d=0x7f020007 a=-1 r=0x7f020007}
E/AndroidRuntime( 1969): at android.content.res.Resources.loadDrawable(Resources.java:1899)
E/AndroidRuntime( 1969): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
E/AndroidRuntime( 1969): at android.view.View.<init>(View.java:2785)
E/AndroidRuntime( 1969): at android.view.ViewGroup.<init>(ViewGroup.java:385)
E/AndroidRuntime( 1969): at android.widget.LinearLayout.<init>(LinearLayout.java:174)
E/AndroidRuntime( 1969): at androi
D/dalvikvm( 1969): GC_CONCURRENT freed 874K, 14% free 6176K/7175K, paused 3ms+2ms
注意到最下面一个,报的是资源文件无法找到。经过反复的排查,发现之前跟UI拿图片的时候,有些图片带大写。比如正常应该是这样:**.png,而拿到的图片却是这样:**.PNG,我们知道Eclipse资源目录是不认大写的,全部需要小写字母,所以同事直接在windows 下改成**.png ,后在Eclipse 跑,良好,但到了源码下编译后就悲剧了。
解决办法:
最好与UI那边协商,让其给图片的时候统一保存为小写后缀。要么就得自己经过专业图片处理软件自己保存。这个问题虽说是小问题,但极其蛋疼。。。。。。稍不注意会让你有抓蛋自杀的念头。