android - 从Marketplace下载带有两个Launcher组件的应用程序后,点击 "Open"会导致崩溃

标签 android marketplace app-launcher

创建一个带有两个启动器图标的示例应用程序。例如,两个 组件如:

<application ...> 
  <activity ... android:name="TestActivity01"> 
    <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 
      <category android:name="android.intent.category.LAUNCHER" /> 
    </intent-filter> 
  </activity> 
  <activity ... android:name="TestActivity02"> 
    <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 
      <category android:name="android.intent.category.LAUNCHER" /> 
    </intent-filter> 
  </activity> 
</application> 

通过从 Marketplace 下载安装应用程序,或通过 应用程序安装程序。当消息框询问您是否要运行 应用程序,抛出异常:

02-03 16:42:44.270: ERROR/AndroidRuntime(395): 
android.content.ActivityNotFoundException: Unable to find explicit activity 
class {com.xxx.xxx/com.android.internal.app.ResolverActivity}; have you 
declared this activity in your AndroidManifest.xml?
02-03 16:42:44.270: ERROR/AndroidRuntime(395):     at 
android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1
480)
02-03 16:42:44.270: ERROR/AndroidRuntime(395):     at 
android.app.Instrumentation.execStartActivity(Instrumentation.java:1454)
02-03 16:42:44.270: ERROR/AndroidRuntime(395):     at 
android.app.Activity.startActivityForResult(Activity.java:2660)
02-03 16:42:44.270: ERROR/AndroidRuntime(395):     at 
android.app.Activity.startActivity(Activity.java:2704)
02-03 16:42:44.270: ERROR/AndroidRuntime(395):     at 
com.android.packageinstaller.InstallAppDone.onClick(InstallAppDone.java:105
)
02-03 16:42:44.270: ERROR/AndroidRuntime(395):     at 
android.view.View.performClick(View.java:2344)
02-03 16:42:44.270: ERROR/AndroidRuntime(395):     at 
android.view.View.onTouchEvent(View.java:4133)
02-03 16:42:44.270: ERROR/AndroidRuntime(395):     at 
android.widget.TextView.onTouchEvent(TextView.java:6504)
02-03 16:42:44.270: ERROR/AndroidRuntime(395):     at 
android.view.View.dispatchTouchEvent(View.java:3672)
02-03 16:42:44.270: ERROR/AndroidRuntime(395):     at 
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882)
02-03 16:42:44.270: ERROR/AndroidRuntime(395):     at 
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882)
02-03 16:42:44.270: ERROR/AndroidRuntime(395):     at 
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882)
02-03 16:42:44.270: ERROR/AndroidRuntime(395):     at 
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882)
02-03 16:42:44.270: ERROR/AndroidRuntime(395):     at 
com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEv
ent(PhoneWindow.java:1712)
02-03 16:42:44.270: ERROR/AndroidRuntime(395):     at 
com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneW
indow.java:1202)
02-03 16:42:44.270: ERROR/AndroidRuntime(395):     at 
android.app.Activity.dispatchTouchEvent(Activity.java:1987)
02-03 16:42:44.270: ERROR/AndroidRuntime(395):     at 
com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(P
honeWindow.java:1696)
02-03 16:42:44.270: ERROR/AndroidRuntime(395):     at 
android.view.ViewRoot.handleMessage(ViewRoot.java:1658)
02-03 16:42:44.270: ERROR/AndroidRuntime(395):     at 
android.os.Handler.dispatchMessage(Handler.java:99)
02-03 16:42:44.270: ERROR/AndroidRuntime(395):     at 
android.os.Looper.loop(Looper.java:123)
02-03 16:42:44.270: ERROR/AndroidRuntime(395):     at 
android.app.ActivityThread.main(ActivityThread.java:4203)
02-03 16:42:44.270: ERROR/AndroidRuntime(395):     at 
java.lang.reflect.Method.invokeNative(Native Method)
02-03 16:42:44.270: ERROR/AndroidRuntime(395):     at 
java.lang.reflect.Method.invoke(Method.java:521)
02-03 16:42:44.270: ERROR/AndroidRuntime(395):     at 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:
791)
02-03 16:42:44.270: ERROR/AndroidRuntime(395):     at 
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
02-03 16:42:44.270: ERROR/AndroidRuntime(395):     at 
dalvik.system.NativeStart.main(Native Method)

崩溃的发生是因为 com.android.internal.app.ResolverActivity 是 试图找到解决以下 Intent 的(单个)组件:

  <action android:name="android.intent.action.MAIN" /> 
  <category android:name="android.intent.category.LAUNCHER" /> 

请注意,这已经通过 AppInstaller 和 真实设备上的真实市场。

最佳答案

Mike 的解决方案对我有用:

请注意, Activity 别名标签必须在您引用的 Activity 标签之后声明(在 xml 中)。

参见 http://code.google.com/p/android/issues/detail?id=6579

Moussa.Mike 的评论 2,2010 年 3 月 30 日

要获得适当的解决方法,请将此 Activity 别名添加到您的 list 中:

<activity-alias android:name="com.android.internal.app.ResolverActivity"
                android:targetActivity=".Main" android:exported="true">

.Main 替换为您要在启动时作为默认值启动的 .ClassName 在这种情况下点击打开按钮

关于android - 从Marketplace下载带有两个Launcher组件的应用程序后,点击 "Open"会导致崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2244781/

相关文章:

android - 如何使用Android Studio导出jar文件?

android - 尝试获取位置时避免 Google 提示

crash - 仅当从商店下载时 Windows Phone 应用程序才会崩溃

eclipse - 由于巨大的类路径,GWT 启动器出现错误

javascript - 浏览器自动在主屏幕上为 web 应用程序 android 生成启动器图标

java - 汉宁(von Hann)窗

windows-phone-7 - WP7 "rate and review"的链接是什么?

windows-7 - Eclipse Indigo 市场问题——权限被拒绝(?)

ios - 使用 Objective-C 从 IOS 上的提醒中打开我的应用程序

Android Studio :An alert box showed when I try to add RecyclerView