有時候開發(fā)中拒贱,明明有布局文件节仿,而且代碼中只加載布局文件,卻提示資源找不到,報如下錯誤笼吟,找了又找春畔,布局文件明明存在啊仗谆,這TM什么莫名其妙的錯誤碗啄?!
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.shangche.tachograph/com.shangche.tachograph.facee.Test}: android.content.res.Resources$NotFoundException: Resource ID #0x7f04003e
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2581)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2656)
at android.app.ActivityThread.access$800(ActivityThread.java:178)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1512)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5691)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f04003e
at android.content.res.Resources.getValue(Resources.java:1483)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2951)
at android.content.res.Resources.getLayout(Resources.java:1257)
at android.view.LayoutInflater.inflate(LayoutInflater.java:412)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:430)
at android.app.Activity.setContentView(Activity.java:2217)
at com.shangche.tachograph.facee.Test.onCreate(Test.java:19)
at android.app.Activity.performCreate(Activity.java:6142)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1115)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2528)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2656)
at android.app.ActivityThread.access$800(ActivityThread.java:178)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1512)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5691)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
仔細(xì)檢查發(fā)現(xiàn)犁钟,原來配置文件中指定了豎屏棱诱,而布局文件是放在橫屏文件夾下,而指定了豎屏就只會去豎屏文件夾找相應(yīng)的資源文件涝动,所以就會出現(xiàn)找不到的問題迈勋。