Android Studio 2.3.2在工作配置文件或目标设备上的另一个用户帐户下启动应用程序将导致崩溃

vin*_*ade 1 android android-activity android-instant-run

我已经安装了Android Studio 2.3.2版本,我的应用程序已在模拟器以及移动设备上成功运行。进行一些更改后,它无法在移动设备上运行,但在模拟器中可以正常工作。

事件日志:

12:55 PM    Instant Run performed a full build and install since
                    the installation on the device does not match the local build on disk.
                    (Don't show again)

12:55 PM    Instant Run detected that you are running on a target device that has a work profile or multiple user accounts.
                    Launching the app under a work profile or another user account on the target device will result in a crash.
                    Learn more about how to run your app under a work profile.
Run Code Online (Sandbox Code Playgroud)

Sud*_*h R 6

使用此配置您的项目在工作资料中启动应用

如果您使用Instant Run运行应用程序并使用工作配置文件(或其他辅助配置文件)打开您的应用程序 ,则您的应用程序将崩溃,因为只能从主配置文件的用户空间访问Instant Run使用的已检测的DEX文件。

如果要继续使用Instant Run,只需避免使用工作资料打开您的应用程序,并确保您的 运行配置未使用该--user user_id标志。

如果您需要将应用程序与工作资料一起使用,我们建议您创建一个包含该标志的新运行配置--user user_id,并指定工作资料用户ID。您可以通过adb shell pm list users从命令行执行来找到用户ID 。当您使用--user标志时,Android Studio仅针对该部署禁用即时运行;当您切换到不带该--user标志的配置时,即时运行将再次起作用。

要禁用即时运行:

  1. 打开设置或首选项对话框。
  2. 导航到“构建,执行,部署>即时运行”。
  3. 取消选中“启用即时运行”旁边的框。