Android 2.3.3Eclipse Version: 3.7.0LogCat

LogCat 报错信息:

02-07 23:19:47.171: WARN/dalvikvm(825): threadid=1: thread exiting with uncaught exception (group=0x40015560)02-07 23:19:47.221: ERROR/AndroidRuntime(825): FATAL EXCEPTION: main02-07 23:19:47.221: ERROR/AndroidRuntime(825): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.tmall.htc/com.tmall.htc.manage.Config}: android.content.res.Resources$NotFoundException: String resource ID #0x7f07008802-07 23:19:47.221: ERROR/AndroidRuntime(825): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)02-07 23:19:47.221: ERROR/AndroidRuntime(825): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)02-07 23:19:47.221: ERROR/AndroidRuntime(825): at android.app.ActivityThread.access$1500(ActivityThread.java:117)02-07 23:19:47.221: ERROR/AndroidRuntime(825): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)02-07 23:19:47.221: ERROR/AndroidRuntime(825): at android.os.Handler.dispatchMessage(Handler.java:99)02-07 23:19:47.221: ERROR/AndroidRuntime(825): at android.os.Looper.loop(Looper.java:123)02-07 23:19:47.221: ERROR/AndroidRuntime(825): at android.app.ActivityThread.main(ActivityThread.java:3683)02-07 23:19:47.221: ERROR/AndroidRuntime(825): at java.lang.reflect.Method.invokeNative(Native Method)02-07 23:19:47.221: ERROR/AndroidRuntime(825): at java.lang.reflect.Method.invoke(Method.java:507)02-07 23:19:47.221: ERROR/AndroidRuntime(825): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)02-07 23:19:47.221: ERROR/AndroidRuntime(825): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)02-07 23:19:47.221: ERROR/AndroidRuntime(825): at dalvik.system.NativeStart.main(Native Method)02-07 23:19:47.221: ERROR/AndroidRuntime(825): Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x7f07008802-07 23:19:47.221: ERROR/AndroidRuntime(825): at android.content.res.Resources.getText(Resources.java:201)02-07 23:19:47.221: ERROR/AndroidRuntime(825): at android.content.res.Resources.getString(Resources.java:254)02-07 23:19:47.221: ERROR/AndroidRuntime(825): at android.content.Context.getString(Context.java:183)02-07 23:19:47.221: ERROR/AndroidRuntime(825): at com.tmall.htc.manage.Config.getname(Config.java:384)02-07 23:19:47.221: ERROR/AndroidRuntime(825): at com.tmall.htc.manage.Config.setSummary(Config.java:150)02-07 23:19:47.221: ERROR/AndroidRuntime(825): at com.tmall.htc.manage.Config.onCreate(Config.java:88)02-07 23:19:47.221: ERROR/AndroidRuntime(825): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)02-07 23:19:47.221: ERROR/AndroidRuntime(825): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)02-07 23:19:47.221: ERROR/AndroidRuntime(825): ... 11 more

主要错误:

02-07 23:19:47.221: ERROR/AndroidRuntime(825): Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x7f070088


发生错误原因分析:

Activity部分源代码:

public String getname() {String setting = sharedPref.getString(Config.KEY_name,context.getString(R.string.def_name));return setting;} 

Eclispe并未提示R.string.def_name处出错,不存在“def_name cannot be resolved or is not a field”问题;

经反复查找,发现:因为支持国际化,在res下设置了中文和英文两套资源文件,默认资源为中文资源。

英文资源中已有

<string name="def_name">iphone4s</string> 

而中文资源中没有相应配置def_name。

Android虚拟机设置为默认中文,因此运行应用时找不到相应资源而报错。

解决办法:在中文资源中添加上述配置。

更多相关文章

  1. Android的资源获取的相关方法
  2. Android(安卓)中文 API (40) —— RatingBar
  3. android:快速搜索手机中文件
  4. 手机安全卫士开发系列(7)——知识点整理(1)
  5. android intent.setDate方法
  6. Android(安卓)http 请求——AsyncHttpClient集成【解决重定向问
  7. Android(安卓)SDK 在线更新镜像服务器资源
  8. Android(安卓)View(四)-View相关属性详解
  9. Android常用的几种资源

随机推荐

  1. Android的Html类分析与扩展
  2. android:屏幕自适应(转)
  3. Android中的selector
  4. Native+WebApp中Phonegap调用Android(安
  5. botoom tab + title bar
  6. [Android] (Android(安卓)视频悬浮窗)
  7. Android(安卓)响应System UI状态,焦点改变
  8. Android设置Settings:PreferenceFragment
  9. android 自定义 permission 权限
  10. Android(安卓)EventBus源码分析