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

发布于 2024-10-16 05:50:57 字数 5061 浏览 4 评论 0原文

我的一位同事尝试从内部网站加载我的 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 和 Main 的意图过滤器,这就是启动 Activity 之前需要“解决”的问题。显然其他安装者只是抓住一个(随机,第一个,等等)?

    <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>

One of my colleagues was trying to load my APK from an internal web site and then opening it from the installer. The application crashes at launch time with the following stack and referring to an activity that I do not have. I believe it is because I (temporarily) have two entry points for my application from the manifest, therefore, a resolver (chooser) is needed.

Is this true?

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)

Here is a piece of the manifest. Notice the Welcome and the Settings activities. Both have intent filters for Launcher with Main and that is what needs to be "resolved" before starting the activity. Apparently other installers just grab one (at random, first, etc.)?

    <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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

兮颜 2024-10-23 05:50:57

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

Having more than one Activity that matches on the intent-filter may require a Resolver to choose among the matching options. Remove one of the MAIN / LAUNCHER intent filters or add a Resolver with a chooser dialog to launch.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文