从安装崩溃启动Android apk寻找ResolverActivity?

时间:2011-02-04 22:08:30

标签: android installer apk resolver

我的一位同事试图从内部网站加载我的APK,然后从安装程序打开它。应用程序在启动时崩溃,使用以下堆栈并引用我没有的活动。我相信这是因为我(暂时)从清单中为我的应用程序提供了两个入口点,因此需要一个解析器(选择器)。

这是真的吗?

02-04 13:57:15.880 E/AndroidRuntime( 4183): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.mycompany.android.myapp/com.android.internal.app.ResolverActivity}; have you declared this activity in your AndroidManifest.xml?
02-04 13:57:15.880 E/AndroidRuntime( 4183):     at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1404)
02-04 13:57:15.880 E/AndroidRuntime( 4183):     at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
02-04 13:57:15.880 E/AndroidRuntime( 4183):     at android.app.Activity.startActivityForResult(Activity.java:2758)
02-04 13:57:15.880 E/AndroidRuntime( 4183):     at android.app.Activity.startActivity(Activity.java:2864)
02-04 13:57:15.880 E/AndroidRuntime( 4183):     at com.android.packageinstaller.InstallAppProgress.onClick(InstallAppProgress.java:191)
02-04 13:57:15.880 E/AndroidRuntime( 4183):     at android.view.View.performClick(View.java:2420)
02-04 13:57:15.880 E/AndroidRuntime( 4183):     at android.view.View.onTouchEvent(View.java:4235)
02-04 13:57:15.880 E/AndroidRuntime( 4183):     at android.widget.TextView.onTouchEvent(TextView.java:6642)
02-04 13:57:15.880 E/AndroidRuntime( 4183):     at android.view.View.dispatchTouchEvent(View.java:3765)
02-04 13:57:15.880 E/AndroidRuntime( 4183):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
02-04 13:57:15.880 E/AndroidRuntime( 4183):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
02-04 13:57:15.880 E/AndroidRuntime( 4183):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
02-04 13:57:15.880 E/AndroidRuntime( 4183):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
02-04 13:57:15.880 E/AndroidRuntime( 4183):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
02-04 13:57:15.880 E/AndroidRuntime( 4183):     at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1713)
02-04 13:57:15.880 E/AndroidRuntime( 4183):     at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1131)
02-04 13:57:15.880 E/AndroidRuntime( 4183):     at android.app.Activity.dispatchTouchEvent(Activity.java:2070)
02-04 13:57:15.880 E/AndroidRuntime( 4183):     at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1697)
02-04 13:57:15.880 E/AndroidRuntime( 4183):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1716)
02-04 13:57:15.880 E/AndroidRuntime( 4183):     at android.os.Handler.dispatchMessage(Handler.java:99)
02-04 13:57:15.880 E/AndroidRuntime( 4183):     at android.os.Looper.loop(Looper.java:123)
02-04 13:57:15.880 E/AndroidRuntime( 4183):     at android.app.ActivityThread.main(ActivityThread.java:4363)
02-04 13:57:15.880 E/AndroidRuntime( 4183):     at java.lang.reflect.Method.invokeNative(Native Method)
02-04 13:57:15.880 E/AndroidRuntime( 4183):     at java.lang.reflect.Method.invoke(Method.java:521)
02-04 13:57:15.880 E/AndroidRuntime( 4183):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:862)
02-04 13:57:15.880 E/AndroidRuntime( 4183):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
02-04 13:57:15.880 E/AndroidRuntime( 4183):     at dalvik.system.NativeStart.main(Native Method)

这是清单的一部分。请注意“欢迎”和“设置”活动。两者都有Launcher with Main的意图过滤器,这是在开始活动之前需要“解决”的。显然其他安装人员只抓一个(随机,第一个等)?

    <activity android:name=".ui.WelcomeActivity"
              android:label="@string/title_welcome">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>             

    <activity android:name=".ui.AboutActivity"
              android:label="@string/title_edit_profile">
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>

   <activity android:name=".ui.SettingsActivity"
              android:label="@string/title_settings" 
              android:windowSoftInputMode="stateAlwaysHidden|adjustPan">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <action android:name="android.provider.Settings.ACTION_SYNC_SETTINGS"/>
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>

1 个答案:

答案 0 :(得分:0)

在intent-filter上匹配多个Activity可能需要Resolver在匹配选项中进行选择。删除一个MAIN / LAUNCHER意图过滤器或添加带有选择器对话框的解析器以启动。