一打开就报错,类似“
Android: android.content.res.Resources$NotFoundException: Resource ID #0x7f030009
”
google找到一篇: https://bugs.launchpad.net/linaro-android/+bug/772528
其中,网址:
http://git.linaro.org/gitweb?p=android/device/linaro/common.git;a=commitdiff;h=89a3940ca2ad04a54e4a8aa315f0089ce4621d17;hp=cc108a6396661b453085fd4be7011f69acf52d87
这里有个commit解决这个问题,是由于系统中没有touch设备,而Music需要检测系统中存在touch设备
才能工作。
From 89a3940ca2ad04a54e4a8aa315f0089ce4621d17 Mon Sep 17 00:00:00 2001 From: Jim Huang <jim.huang@linaro.org> Date: Wed, 29 Jun 2011 01:22:52 +0800 Subject: [PATCH 1/1] [LINARO] Add fake touchscreen 'driver' to avoid Android activity crash Some Android activities like 'Music' expect the presence of touchscreen device, otherwise they would crash due to lacking of corresponding system resources. To fix the crash, a fake touchscreen 'driver' is added, which utilizes uinput to register a touchscreen device in kernel. --- fake-ts/Android.mk | 30 ++++++++++++++++++++ fake-ts/fake-ts.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 106 insertions(+), 0 deletions(-) create mode 100644 fake-ts/Android.mk create mode 100644 fake-ts/fake-ts.c diff --git a/fake-ts/Android.mk b/fake-ts/Android.mk new file mode 100644 index 0000000..3c3ba4c --- /dev/null +++ b/fake-ts/Android.mk @@ -0,0 +1,30 @@ +# Copyright (C) 2011 Linaro Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +LOCAL_PATH:= $(call my-dir) + +ifneq ($(TARGET_SIMULATOR),true) + +include $(CLEAR_VARS) + +LOCAL_MODULE := faketsd + +LOCAL_MODULE_TAGS := optional + +LOCAL_SRC_FILES := fake-ts.c +LOCAL_PRELINK_MODULE := false + +include $(BUILD_EXECUTABLE) + +endif # !TARGET_SIMULATOR diff --git a/fake-ts/fake-ts.c b/fake-ts/fake-ts.c new file mode 100644 index 0000000..9fe0a20 --- /dev/null +++ b/fake-ts/fake-ts.c @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2011 Linaro Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + */ + +#include <stdio.h> +#include <fcntl.h> +#include <unistd.h> +#include <string.h> + +#include <linux/uinput.h> + +/* look up source file system/core/init/devices.c for exact node */ +#define UINPUT_DEV "/dev/uinput" + +#define DEV_NAME "Fake Touchscreen" + +static int uinput_fd = 0; + +static void uinput_touch_init(const char* uinput_dev, + const char* dev_name) +{ + struct uinput_user_dev dev; + + uinput_fd = open(uinput_dev, O_WRONLY); + if (uinput_fd <= 0) { + perror("Error opening uinput device.\n"); + return; + } + memset(&dev, 0, sizeof(dev)); + strcpy(dev.name, dev_name); + write(uinput_fd, &dev, sizeof(dev)); + + /* touch screen event */ + ioctl(uinput_fd, UI_SET_EVBIT, EV_ABS); + ioctl(uinput_fd, UI_SET_ABSBIT, ABS_X); + ioctl(uinput_fd, UI_SET_ABSBIT, ABS_Y); + ioctl(uinput_fd, UI_SET_EVBIT, EV_KEY); + ioctl(uinput_fd, UI_SET_KEYBIT, BTN_TOUCH); + + /* register userspace input device */ + ioctl(uinput_fd, UI_DEV_CREATE, 0); +} + +static void uinput_touch_deinit() +{ + if (uinput_fd > 0) { + close(uinput_fd); + } +} + +int main(int argc, char* argv[]) +{ + uinput_touch_init(UINPUT_DEV, DEV_NAME); + + while (1) { + sleep(60); + } + + uinput_touch_deinit(); + + return 0; +} + -- 1.7.0.4或者简单点的办法,直接在kernel中选择一个touch的driver,哪怕用不到。
Ok I updated bug heading and here's a list of apps which crash:
* Contacts
* Music
* Phone (seems due to Contacts)
Stack traces below:
E/AndroidRuntime( 1452): java.lang. RuntimeExceptio n: Unable to start activity ComponentInfo{ com.android. contacts/ com.android. contacts. DialtactsActivi ty}: android. content. res.Resources$ NotFoundExcepti on: Resource ID #0x7f03000e app.ActivityThr ead.performLaun chActivity( ActivityThread. java:1647) app.ActivityThr ead.handleLaunc hActivity( ActivityThread. java:1663) app.ActivityThr ead.access$ 1500(ActivityTh read.java: 117) app.ActivityThr ead$H.handleMes sage(ActivityTh read.java: 931) os.Handler. dispatchMessage (Handler. java:99) os.Looper. loop(Looper. java:130) app.ActivityThr ead.main( ActivityThread. java:3683) reflect. Method. invokeNative( Native Method) reflect. Method. invoke( Method. java:507) internal. os.ZygoteInit$ MethodAndArgsCa ller.run( ZygoteInit. java:839) internal. os.ZygoteInit. main(ZygoteInit .java:597) system. NativeStart. main(Native Method) content. res.Resources$ NotFoundExcepti on: Resource ID #0x7f03000e content. res.Resources. getValue( Resources. java:892) content. res.Resources. loadXmlResource Parser( Resources. java:1869) content. res.Resources. getLayout( Resources. java:731) view.LayoutInfl ater.inflate( LayoutInflater. java:318) view.LayoutInfl ater.inflate( LayoutInflater. java:276) internal. policy. impl.PhoneWindo w.setContentVie w(PhoneWindow. java:207) app.Activity. setContentView( Activity. java:1657) contacts. DialtactsActivi ty.onCreate( DialtactsActivi ty.java: 69) app.Instrumenta tion.callActivi tyOnCreate( Instrumentation .java:1047) app.ActivityThr ead.performLaun chActivity( ActivityThread. java:1611)
E/AndroidRuntime( 1452): at android.
E/AndroidRuntime( 1452): at android.
E/AndroidRuntime( 1452): at android.
E/AndroidRuntime( 1452): at android.
E/AndroidRuntime( 1452): at android.
E/AndroidRuntime( 1452): at android.
E/AndroidRuntime( 1452): at android.
E/AndroidRuntime( 1452): at java.lang.
E/AndroidRuntime( 1452): at java.lang.
E/AndroidRuntime( 1452): at com.android.
E/AndroidRuntime( 1452): at com.android.
E/AndroidRuntime( 1452): at dalvik.
E/AndroidRuntime( 1452): Caused by: android.
E/AndroidRuntime( 1452): at android.
E/AndroidRuntime( 1452): at android.
E/AndroidRuntime( 1452): at android.
E/AndroidRuntime( 1452): at android.
E/AndroidRuntime( 1452): at android.
E/AndroidRuntime( 1452): at com.android.
E/AndroidRuntime( 1452): at android.
E/AndroidRuntime( 1452): at com.android.
E/AndroidRuntime( 1452): at android.
E/AndroidRuntime( 1452): at android.
E/AndroidRuntime( 1452): ... 11 more
E/AndroidRuntime( 1484): java.lang. RuntimeExceptio n: Unable to start activity ComponentInfo{ com.android. music/com. android. music.ArtistAlb umBrowserActivi ty}: android. content. res.Resources$ NotFoundExcepti on: Resource ID #0x7f030009 app.ActivityThr ead.performLaun chActivity( ActivityThread. java:1647) app.ActivityThr ead.handleLaunc hActivity( ActivityThread. java:1663) app.ActivityThr ead.access$ 1500(ActivityTh read.java: 117) app.ActivityThr ead$H.handleMes sage(ActivityTh read.java: 931)
E/AndroidRuntime( 1484): at android.
E/AndroidRuntime( 1484): at android.
E/AndroidRuntime( 1484): at android.
E/AndroidRuntime( 1484): at android.
E/AndroidRuntime( 1484)...