获取android.content.res.Resources $ NotFoundException:例外,甚至当资源是present在安卓 [英] Getting android.content.res.Resources$NotFoundException: exception even when the resource is present in android

查看:122
本文介绍了获取android.content.res.Resources $ NotFoundException:例外,甚至当资源是present在安卓的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请让我知道我错了获得错误

我创建一个应用程序具有其活性中的一个作为只在横向模式。所以我加了以下的的Andr​​oidManifest.xml 的文件

 <活动机器人:LandScapeImageActivity名称=机器人:screenOrientation =山水和GT;< /活性GT;
 

我创建了一个文件夹,如

  

/ RES /布局土地

和在其中添加一个名为see_today_landscape_layout布局。

的onCreate()添加以下

 保护无效的onCreate(包savedInstanceState){
    super.onCreate(savedInstanceState);
    的setContentView(R.layout.see_today_landscape_layout);
....
}
 

但是,当我跑我的应用程序,我收到以下错误

  02-06 13:46:14.358:E / AndroidRuntime(13286):致命异常:主要
02-06 13:46:14.358:E / AndroidRuntime(13286):java.lang.RuntimeException的:无法启动的活动ComponentInfo {com.mid.kew.activities / com.mid.kew.activities.LandScapeImageActivity}:android.content .res.Resources $ NotFoundException:资源ID#0x7f03002b
02-06 13:46:14.358:E / AndroidRuntime(13286):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2787)
02-06 13:46:14.358:E / AndroidRuntime(13286):在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2803)
02-06 13:46:14.358:E / AndroidRuntime(13286):在android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4066)
02-06 13:46:14.358:E / AndroidRuntime(13286):在android.app.ActivityThread.access $ 2400(ActivityThread.java:135)
02-06 13:46:14.358:E / AndroidRuntime(13286):在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:2140)
02-06 13:46:14.358:E / AndroidRuntime(13286):在android.os.Handler.dispatchMessage(Handler.java:99)
02-06 13:46:14.358:E / AndroidRuntime(13286):在android.os.Looper.loop(Looper.java:144)
02-06 13:46:14.358:E / AndroidRuntime(13286):在android.app.ActivityThread.main(ActivityThread.java:4937)
02-06 13:46:14.358:E / AndroidRuntime(13286):在java.lang.reflect.Method.invokeNative(本机方法)
02-06 13:46:14.358:E / AndroidRuntime(13286):在java.lang.reflect.Method.invoke(Method.java:521)
02-06 13:46:14.358:E / AndroidRuntime(13286):在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:868)
02-06 13:46:14.358:E / AndroidRuntime(13286):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
02-06 13:46:14.358:E / AndroidRuntime(13286):在dalvik.system.NativeStart.main(本机方法)
02-06 13:46:14.358:E / AndroidRuntime(13286):android.content.res.Resources $ NotFoundException:由造成资源ID#0x7f03002b
02-06 13:46:14.358:E / AndroidRuntime(13286):在android.content.res.Resources.getValue(Resources.java:892)
02-06 13:46:14.358:E / AndroidRuntime(13286):在android.content.res.Resources.loadXmlResourceParser(Resources.java:1869)
02-06 13:46:14.358:E / AndroidRuntime(13286):在android.content.res.Resources.getLayout(Resources.java:731)
02-06 13:46:14.358:E / AndroidRuntime(13286):在android.view.LayoutInflater.inflate(LayoutInflater.java:318)
02-06 13:46:14.358:E / AndroidRuntime(13286):在android.view.LayoutInflater.inflate(LayoutInflater.java:276)
02-06 13:46:14.358:E / AndroidRuntime(13286):在com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
02-06 13:46:14.358:E / AndroidRuntime(13286):在android.app.Activity.setContentView(Activity.java:1654)
02-06 13:46:14.358:E / AndroidRuntime(13286):在com.mid.kew.activities.LandScapeImageActivity.onCreate(LandScapeImageActivity.java:103)
02-06 13:46:14.358:E / AndroidRuntime(13286):在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1069)
02-06 13:46:14.358:E / AndroidRuntime(13286):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2751)
02-06 13:46:14.358:E / AndroidRuntime(13286):12 ...更多
 

我穿越托运的 R.java 的,它有与ID 7f03002b该异常寻找资源,这是present在那里......

我清理和重建项目,比如5倍,但问题仍然存在。

奇怪的一点是,这是今天昨天的工作和不工作。在code是相同的。

请请让我知道该怎么做。

我坚持和沮丧。

拉​​吉

解决方案
  1. 在Eclipse中,转到项目>清洁...
  2. 选择您的项目,那么preSS确定
  3. 重新启动应用程序

如果它发生再次删除r.java文件。它会自动生成。

Please let me know where I am going wrong to get the error

I am creating an app which have one of its activity to be only in landscape mode. So I added the following in AndroidManifest.xml file

<activity android:name=".LandScapeImageActivity" android:screenOrientation="landscape"></activity>

I have created a folder like

/res/layout-land

and add a layout called see_today_landscape_layout in it.

and in onCreate() I added the following

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.see_today_landscape_layout);
....
}

But when I run my app I am getting the following error

02-06 13:46:14.358: E/AndroidRuntime(13286): FATAL EXCEPTION: main
02-06 13:46:14.358: E/AndroidRuntime(13286): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mid.kew.activities/com.mid.kew.activities.LandScapeImageActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x7f03002b
02-06 13:46:14.358: E/AndroidRuntime(13286):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2787)
02-06 13:46:14.358: E/AndroidRuntime(13286):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2803)
02-06 13:46:14.358: E/AndroidRuntime(13286):    at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4066)
02-06 13:46:14.358: E/AndroidRuntime(13286):    at android.app.ActivityThread.access$2400(ActivityThread.java:135)
02-06 13:46:14.358: E/AndroidRuntime(13286):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2140)
02-06 13:46:14.358: E/AndroidRuntime(13286):    at android.os.Handler.dispatchMessage(Handler.java:99)
02-06 13:46:14.358: E/AndroidRuntime(13286):    at android.os.Looper.loop(Looper.java:144)
02-06 13:46:14.358: E/AndroidRuntime(13286):    at android.app.ActivityThread.main(ActivityThread.java:4937)
02-06 13:46:14.358: E/AndroidRuntime(13286):    at java.lang.reflect.Method.invokeNative(Native Method)
02-06 13:46:14.358: E/AndroidRuntime(13286):    at java.lang.reflect.Method.invoke(Method.java:521)
02-06 13:46:14.358: E/AndroidRuntime(13286):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
02-06 13:46:14.358: E/AndroidRuntime(13286):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
02-06 13:46:14.358: E/AndroidRuntime(13286):    at dalvik.system.NativeStart.main(Native Method)
02-06 13:46:14.358: E/AndroidRuntime(13286): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f03002b
02-06 13:46:14.358: E/AndroidRuntime(13286):    at android.content.res.Resources.getValue(Resources.java:892)
02-06 13:46:14.358: E/AndroidRuntime(13286):    at android.content.res.Resources.loadXmlResourceParser(Resources.java:1869)
02-06 13:46:14.358: E/AndroidRuntime(13286):    at android.content.res.Resources.getLayout(Resources.java:731)
02-06 13:46:14.358: E/AndroidRuntime(13286):    at android.view.LayoutInflater.inflate(LayoutInflater.java:318)
02-06 13:46:14.358: E/AndroidRuntime(13286):    at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
02-06 13:46:14.358: E/AndroidRuntime(13286):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
02-06 13:46:14.358: E/AndroidRuntime(13286):    at android.app.Activity.setContentView(Activity.java:1654)
02-06 13:46:14.358: E/AndroidRuntime(13286):    at com.mid.kew.activities.LandScapeImageActivity.onCreate(LandScapeImageActivity.java:103)
02-06 13:46:14.358: E/AndroidRuntime(13286):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1069)
02-06 13:46:14.358: E/AndroidRuntime(13286):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2751)
02-06 13:46:14.358: E/AndroidRuntime(13286):    ... 12 more

I crossed checked in R.java and it has the resource with the ID 7f03002b which the exception is looking for and it is present in there...

I cleaned and rebuild the project for say 5 times, but still the issue occurs.

Strange point is that this was working yesterday and its not working today. The code is the same.

Please Please let me know what to do.

I am stuck and frustrated.

Raj

解决方案

  1. in eclipse, go to Project > Clean...
  2. select your project, then press OK
  3. relaunch the app

if it happens again delete the r.java file. it will generate automatically.

这篇关于获取android.content.res.Resources $ NotFoundException:例外,甚至当资源是present在安卓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆