无法为广播意图启动应用程序

Posted

技术标签:

【中文标题】无法为广播意图启动应用程序【英文标题】:Unable to launch app for broadcast intent 【发布时间】:2011-06-12 01:11:51 【问题描述】:

我写了一个小时钟小部件。像所有时钟一样,它必须每分钟更新一次。所以我设置了一个警报来做到这一点。它工作得很好。它只是有点太小了。所以我摆弄了一个 XML 属性并再次尝试。它强制关闭。我将属性改回原来的并再次尝试。它再次强制关闭。

LogCat 如下(从包安装到操作系统杀死它):

01-19 13:38:52.292: DEBUG/PackageManager(57): New package installed in /data/app/com.---.clock-2.apk
01-19 13:38:52.571: INFO/ActivityManager(57): Force stopping package com.---.clock uid=10043
01-19 13:38:52.571: INFO/Process(57): Sending signal. PID: 593 SIG: 9
01-19 13:38:52.612: INFO/ActivityManager(57): Force stopping package com.---.clock uid=10043
01-19 13:38:53.022: DEBUG/PhotoAppWidgetProvider(282): getPhoto query count=0
01-19 13:38:53.022: DEBUG/PhotoAppWidgetProvider(282): sending out views=null for id=0
01-19 13:38:53.131: INFO/ActivityManager(57): Start proc com.---.clock for broadcast com.---.clock/.Clock: pid=613 uid=10043 gids=1015
01-19 13:38:53.713: DEBUG/Clock widget(613): updated
01-19 13:38:54.011: INFO/ActivityManager(57): Force stopping package com.---.clock uid=10043
01-19 13:38:54.021: INFO/Process(57): Sending signal. PID: 613 SIG: 9
01-19 13:38:54.301: DEBUG/dalvikvm(121): GC_EXPLICIT freed 13673 objects / 524360 bytes in 177ms
01-19 13:38:54.542: DEBUG/dalvikvm(125): GC_EXPLICIT freed 4956 objects / 200960 bytes in 440ms
01-19 13:38:54.801: WARN/RecognitionManagerService(57): no available voice recognition services found
01-19 13:38:55.032: DEBUG/dalvikvm(57): GC_EXPLICIT freed 4960 objects / 290104 bytes in 201ms
01-19 13:38:55.042: INFO/installd(35): unlink /data/dalvik-cache/data@app@com.---.clock-1.apk@classes.dex
01-19 13:38:55.131: DEBUG/androidRuntime(605): Shutting down VM
01-19 13:38:55.151: DEBUG/dalvikvm(605): Debugger has detached; object registry had 1 entries
01-19 13:38:55.212: INFO/AndroidRuntime(605): NOTE: attach of thread 'Binder Thread #3' failed
01-19 13:38:55.571: DEBUG/PhotoAppWidgetProvider(282): getPhoto query count=0
01-19 13:38:55.571: DEBUG/PhotoAppWidgetProvider(282): sending out views=null for id=0
01-19 13:38:55.762: INFO/ActivityManager(57): Start proc com.---.clock for broadcast com.---.clock/.Clock: pid=622 uid=10043 gids=1015
01-19 13:38:56.332: WARN/asset(622): Asset path /data/app/com.---.clock-1.apk is neither a directory nor file (type=1).
01-19 13:38:56.373: DEBUG/AndroidRuntime(622): Shutting down VM
01-19 13:38:56.373: WARN/dalvikvm(622): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
01-19 13:38:56.722: DEBUG/PhotoAppWidgetProvider(282): getPhoto query count=0
01-19 13:38:56.732: DEBUG/PhotoAppWidgetProvider(282): sending out views=null for id=0
01-19 13:38:56.841: ERROR/AndroidRuntime(622): FATAL EXCEPTION: main
01-19 13:38:56.841: ERROR/AndroidRuntime(622): java.lang.RuntimeException: Unable to instantiate receiver com.---.clock.Clock: java.lang.ClassNotFoundException: com.---.clock.Clock in loader dalvik.system.PathClassLoader[/data/app/com.---.clock-1.apk]
01-19 13:38:56.841: ERROR/AndroidRuntime(622):     at android.app.ActivityThread.handleReceiver(ActivityThread.java:2789)
01-19 13:38:56.841: ERROR/AndroidRuntime(622):     at android.app.ActivityThread.access$3200(ActivityThread.java:125)
01-19 13:38:56.841: ERROR/AndroidRuntime(622):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2083)
01-19 13:38:56.841: ERROR/AndroidRuntime(622):     at android.os.Handler.dispatchMessage(Handler.java:99)
01-19 13:38:56.841: ERROR/AndroidRuntime(622):     at android.os.Looper.loop(Looper.java:123)
01-19 13:38:56.841: ERROR/AndroidRuntime(622):     at android.app.ActivityThread.main(ActivityThread.java:4627)
01-19 13:38:56.841: ERROR/AndroidRuntime(622):     at java.lang.reflect.Method.invokeNative(Native Method)
01-19 13:38:56.841: ERROR/AndroidRuntime(622):     at java.lang.reflect.Method.invoke(Method.java:521)
01-19 13:38:56.841: ERROR/AndroidRuntime(622):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
01-19 13:38:56.841: ERROR/AndroidRuntime(622):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
01-19 13:38:56.841: ERROR/AndroidRuntime(622):     at dalvik.system.NativeStart.main(Native Method)
01-19 13:38:56.841: ERROR/AndroidRuntime(622): Caused by: java.lang.ClassNotFoundException: com.---.clock.Clock in loader dalvik.system.PathClassLoader[/data/app/com.---.clock-1.apk]
01-19 13:38:56.841: ERROR/AndroidRuntime(622):     at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
01-19 13:38:56.841: ERROR/AndroidRuntime(622):     at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
01-19 13:38:56.841: ERROR/AndroidRuntime(622):     at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
01-19 13:38:56.841: ERROR/AndroidRuntime(622):     at android.app.ActivityThread.handleReceiver(ActivityThread.java:2780)
01-19 13:38:56.841: ERROR/AndroidRuntime(622):     ... 10 more
01-19 13:38:56.901: WARN/asset(57): Asset path /data/app/com.---.clock-1.apk is neither a directory nor file (type=1).
01-19 13:38:56.913: WARN/PackageManager(57): Failure retrieving resources forcom.---.clock
01-19 13:38:57.932: DEBUG/PhotoAppWidgetProvider(282): getPhoto query count=0
01-19 13:38:58.003: DEBUG/PhotoAppWidgetProvider(282): sending out views=null for id=0
01-19 13:39:05.101: INFO/Process(622): Sending signal. PID: 622 SIG: 9
01-19 13:39:05.151: INFO/ActivityManager(57): Process com.---.clock (pid 622) has died.
01-19 13:39:05.182: WARN/InputManagerService(57): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@43ecc698
01-19 13:39:05.892: DEBUG/PhotoAppWidgetProvider(282): getPhoto query count=0
01-19 13:39:05.892: DEBUG/PhotoAppWidgetProvider(282): sending out views=null for id=0
01-19 13:39:06.011: INFO/ActivityManager(57): Start proc com.---.clock for broadcast com.---.clock/.Clock: pid=630 uid=10043 gids=1015
01-19 13:39:06.413: WARN/asset(630): Asset path /data/app/com.---.clock-1.apk is neither a directory nor file (type=1).
01-19 13:39:06.472: DEBUG/AndroidRuntime(630): Shutting down VM
01-19 13:39:06.482: WARN/dalvikvm(630): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
01-19 13:39:06.901: ERROR/AndroidRuntime(630): FATAL EXCEPTION: main
01-19 13:39:06.901: ERROR/AndroidRuntime(630): java.lang.RuntimeException: Unable to instantiate receiver com.---.clock.Clock: java.lang.ClassNotFoundException: com.---.clock.Clock in loader dalvik.system.PathClassLoader[/data/app/com.---.clock-1.apk]
01-19 13:39:06.901: ERROR/AndroidRuntime(630):     at android.app.ActivityThread.handleReceiver(ActivityThread.java:2789)
01-19 13:39:06.901: ERROR/AndroidRuntime(630):     at android.app.ActivityThread.access$3200(ActivityThread.java:125)
01-19 13:39:06.901: ERROR/AndroidRuntime(630):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2083)
01-19 13:39:06.901: ERROR/AndroidRuntime(630):     at android.os.Handler.dispatchMessage(Handler.java:99)
01-19 13:39:06.901: ERROR/AndroidRuntime(630):     at android.os.Looper.loop(Looper.java:123)
01-19 13:39:06.901: ERROR/AndroidRuntime(630):     at android.app.ActivityThread.main(ActivityThread.java:4627)
01-19 13:39:06.901: ERROR/AndroidRuntime(630):     at java.lang.reflect.Method.invokeNative(Native Method)
01-19 13:39:06.901: ERROR/AndroidRuntime(630):     at java.lang.reflect.Method.invoke(Method.java:521)
01-19 13:39:06.901: ERROR/AndroidRuntime(630):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
01-19 13:39:06.901: ERROR/AndroidRuntime(630):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
01-19 13:39:06.901: ERROR/AndroidRuntime(630):     at dalvik.system.NativeStart.main(Native Method)
01-19 13:39:06.901: ERROR/AndroidRuntime(630): Caused by: java.lang.ClassNotFoundException: com.---.clock.Clock in loader dalvik.system.PathClassLoader[/data/app/com.---.clock-1.apk]
01-19 13:39:06.901: ERROR/AndroidRuntime(630):     at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
01-19 13:39:06.901: ERROR/AndroidRuntime(630):     at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
01-19 13:39:06.901: ERROR/AndroidRuntime(630):     at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
01-19 13:39:06.901: ERROR/AndroidRuntime(630):     at android.app.ActivityThread.handleReceiver(ActivityThread.java:2780)
01-19 13:39:06.901: ERROR/AndroidRuntime(630):     ... 10 more
01-19 13:39:06.901: DEBUG/PhotoAppWidgetProvider(282): getPhoto query count=0
01-19 13:39:06.922: DEBUG/PhotoAppWidgetProvider(282): sending out views=null for id=0
01-19 13:39:07.051: WARN/ActivityManager(57): Process com.---.clock has crashed too many times: killing!
01-19 13:39:07.062: INFO/Process(57): Sending signal. PID: 630 SIG: 9
01-19 13:39:07.151: WARN/ActivityManager(57): Unable to launch app com.---.clock/10043 for broadcast Intent  act=android.appwidget.action.APPWIDGET_UPDATE cmp=com.---.clock/.Clock (has extras) : process is bad
01-19 13:39:07.151: WARN/ActivityManager(57): finishReceiver called but none active

我以前从未见过此错误,也不知道是什么原因造成的,也不知道如何解决。有人可以帮我解释一下吗?

【问题讨论】:

"资产路径 /data/app/com.---.clock-1.apk 既不是目录也不是文件 (type=1)。" - 抱歉,我无法给出具体答案,但我昨晚看到了与此非常相似的内容(-1.apk 不是文件/目录错误)。我手动卸载了我的应用程序,删除了我的 .apk 文件,然后重新安装。如果您还没有这样做,可能值得一试。 @MisterSquonk:这句话也让我觉得很可疑,但是,卸载和重新安装都不起作用。出于某种原因,重新启动模拟器确实... 这似乎是数据损坏或dex编译不正确的问题。我会和 MisterSquonk 一起寻求解决方案。 【参考方案1】:

无论出于何种原因,(MAGIC!) 重新启动模拟器都有效。我仍然不知道为什么它一开始就搞砸了,但是重启成功了。

【讨论】:

+1 链接 - 当有人让我想起那个故事时,我总是会心一笑。 我在 logcat 中的设备上有相同的错误代码。重新启动设备也有效 - 因此您的解决方案也适用于设备。

以上是关于无法为广播意图启动应用程序的主要内容,如果未能解决你的问题,请参考以下文章

广播接收器没有收到额外的

sdcard的android意图准备好了

广播受保护的意图时出现 SecurityException

Android 共享意图无法启动

从网站下载 apk 时无法通过意图启动电子邮件

无法启动服务意图