Android - Android 6.0 - 申请流程 - 服务流程

Android - Android 6.0 - Application process - Service process

我正在开发一个提供服务的 android 应用程序。

我希望应用程序和服务 运行 在一个进程中。

我的清单:

<application
    android:process="@string/my_process"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        ...
    </activity>

    <service
        android:name=".core.MessengerService"
        android:enabled="true"
        android:process="@string/my_process" >
        <intent-filter>
            ...
        </intent-filter>
    </service>

    ...

</application>

但是当我在 Android 6.0 设备上逐步调试我的应用程序时,我收到了冻结消息 "Application is waiting for the debugger to attach @my_progress ..."。 (我的 Android 4.4 设备上没有出现此问题)

当我将应用程序和服务分成 2 个不同的进程时,调试在我的 Android 6.0 设备上正常工作。

I'd like to have the application and the service running on one process.

然后删除清单中的所有 android:process 属性。默认是所有组件 运行 在一个进程中。

And when I seperate the application and the service into 2 different proccesses

那不会发生。 Application 单例在每个进程中创建。