无法运行应用程序 - “目标设备不支持'run-as'命令”

4
第一次在Macbook上运行Android Studio时,我遇到了这个错误。程序没有在我的设备上启动,我只收到了一个崩溃消息。
在Android Studio上,我看到“目标设备不支持‘run-as’命令”,当我把它输入Google时,没有结果出现。我看到一个“了解更多”部分,它指向标题为“关于即时运行”的链接:https://developer.android.com/studio/run/index.html?utm_medium=android-studio#instant-run
如果您有任何建议,将不胜感激。

你在哪里遇到了错误?能截个图吗?你使用的是什么设备?你的minSDK是多少?你的设备API/版本是什么?请编辑问题回答这些问题,否则我们无法帮助你。如果你编辑后提醒我,我会取消踩的评价。 - Ali Bdeir
2个回答

3

我最近升级到AS 2.2版本,今天突然出现了这个消息。 重新启动Studio后,此消息消失了。

但是构建过程似乎很慢 - 所以我使用adb命令来停止和启动服务器,现在即时运行功能似乎工作得更好了。

adb kill-server
adb start-server

我的手机是Moto G x1032,运行的是Lollipop系统。


1
只是重新启动Android Studio就解决了我的问题。谢谢。 - ban-geoengineering

0

在我对设备进行了root之后,我遇到了同样的问题,而其他答案并没有解决它。 当我在终端中运行adb run-as命令时,我一直得到以下提示:

    Could not set Capabilities: operation not permitted.

这是一个权限问题。您需要更改/system/bin文件夹中的run-as文件的权限。这对我解决了问题(需要root访问):

    1. remount /system rw
    2. chmod 4750 /system/bin/run-as
    3. remount /system ro

如果运行自定义恢复:
    1. reboot to recovery
    2. find the mount system and check it (make sure 'mount system as read-only' is unchecked)
    3. open a terminal and type: adb shell
    4. type: chmod 4750 /system/bin/run-as
    5. uncheck the System mount and reboot! 

请参考问题58373: https://code.google.com/p/android/issues/detail?id=58373


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接