错误:无法访问包管理器。系统在运行吗?- 在 Android Studio

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21526565/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 04:42:44  来源:igfitidea点击:

Error: Could not access the Package Manager. Is the system running? - At Android Studio

androidandroid-studioruntime-erroremulation

提问by nazar_art

I installed android studio and tried to run easy projects.

我安装了 android studio 并尝试运行简单的项目。

But I caught strange error message:

但我发现了奇怪的错误信息:

Waiting for device.
/usr/local/idea/android-studio/sdk/tools/emulator -avd Nexus-4-18-xhdpi -netspeed full -netdelay none

emulator: emulator window was out of view and was recentered

Device connected: emulator-5554
Device is online: emulator-5554
Target device: Nexus-4-18-xhdpi [emulator-5554]
Uploading file
    local path: /home/nazar/Documents/coursera-android/Examples/HelloAndroid/out/production/HelloAndroid/HelloAndroid.apk
    remote path: /data/local/tmp/course.examples.HelloWorld.HelloWorld
Installing course.examples.HelloWorld.HelloWorld
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/course.examples.HelloWorld.HelloWorld"
Error: Could not access the Package Manager.  Is the system running?

I couldn't figure out why this happen?

我想不通为什么会这样?

I installed sdk version and configured emulator. Any suggestions?

我安装了 sdk 版本并配置了模拟器。有什么建议?

Here is emulator confiuration:

这是模拟器配置:

emulator confiuration

模拟器配置

Update:

更新:

I tried to install Genymotion device and use few virtual devices, but caught:

我尝试安装 Genymotion 设备并使用很少的虚拟设备,但发现:

Waiting for device.
Target device: genymotion-nexus_4___4_4_2___api_19___768x1280-192.168.56.101:5555
Uploading file
    local path: /home/nazar/Documents/coursera-android/Examples/HelloAndroid/out/production/HelloAndroid/HelloAndroid.apk
    remote path: /data/local/tmp/course.examples.HelloWorld.HelloWorld
Installing course.examples.HelloWorld.HelloWorld
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/course.examples.HelloWorld.HelloWorld"
WARNING: linker: libdvm.so has text relocations. This is wasting memory and is a security risk. Please fix.
Error: Could not access the Package Manager.  Is the system running?

How to solve this error?

如何解决这个错误?

采纳答案by pyus13

First make sure you are running Android Studio version above 0.3.2 because there was some issue reported regarding the same in AS 0.3.2 . If it is not you can update it from Help >Check for update.

首先确保您运行的是高于 0.3.2 的 Android Studio 版本,因为在 AS 0.3.2 中报告了一些与此相关的问题。如果不是,您可以从Help >Check for update.

If you are already running AS above 0.3.2 :

如果您已经在 0.3.2 以上运行 AS:

Seems like issue is with your emulator not with Android Studio. It may happen that you are trying to install application before even the emulator started properly.

似乎问题在于您的模拟器而不是 Android Studio。您可能会在模拟器正常启动之前尝试安装应用程序。

Wait till the home screen appears in the emulator before trying to install any application.

等待主屏幕出现在模拟器中,然后再尝试安装任何应用程序。

Also try to install any apk in Emulator from command line

还尝试从命令行在模拟器中安装任何 apk

Steps to install

安装步骤

  • Go to $Android_SDK_DIR\platform-tools, right click there keeping shift key pressed and Chose "Open Command Window here".
  • Run command adb devicesto make sure yout emulator is running properly. It will show all your running emulators.
  • Now if emulators are showing properly, type the command adb install YOUR_FULL_APK_PATH, YOUR_FULL_APK_PATH is of any .apk file path in your system.
  • 转到 $Android_SDK_DIR\platform-tools,右键单击那里并按住 shift 键并选择“在此处打开命令窗口”。
  • 运行命令adb devices以确保您的模拟器运行正常。它将显示您所有正在运行的模拟器。
  • 现在,如果模拟器显示正确,请键入命令adb install YOUR_FULL_APK_PATH, YOUR_FULL_APK_PATH 是系统中任何 .apk 文件路径。

Please update if this works fine.

如果这工作正常,请更新。

回答by Abhishek2k6

The most common cause of this error is simple: You have to manually unlock your Android Virtual Device by swiping the “lock” icon on the screen. Security measures prevent the emulator from letting you connect the debugger before doing this.

此错误的最常见原因很简单:您必须通过滑动屏幕上的“锁定”图标来手动解锁您的 Android 虚拟设备。安全措施可防止模拟器让您在执行此操作之前连接调试器。

The problem is resolved:

问题已解决:

In Android Studio

在 Android Studio 中

  1. Start run/debug
  2. if you see the message
  3. Do not closed the AVD, just click on run/debug again, the Application will be running when you unlock the application.
  1. 开始运行/调试
  2. 如果你看到消息
  3. 不要关闭 AVD,只需再次单击运行/调试,当您解锁应用程序时,应用程序将运行。

回答by Juan Tomaylla

The same problem but different solution, I modified my Virtual Device, I changed Memory option and Internal Storage, and it works fine. RAM:512 , VM HEap: 192, Internal Storage=200, SD Card Size: 200 for Device Nexus 4 android 4.2.2.

同样的问题但不同的解决方案,我修改了我的虚拟设备,我改变了内存选项和内部存储,它工作正常。RAM:512, VM HEap: 192, Internal Storage=200, SD Card Size: 200 for Device Nexus 4 android 4.2.2。

回答by yuliskov

In my case this error was caused by SELinux. I got to set SELinux to permissive.

就我而言,此错误是由 SELinux 引起的。我必须将 SELinux 设置为宽松。

adb shell su 0 setenforce 0

回答by Bob A

I had this issue, but I found that simply killing the emulator and restarting it worked. There seems to be some sort of race condition where the emulator has not initialized before Android Studio tries to launch the apk and so you get the package error.

我遇到了这个问题,但我发现只需杀死模拟器并重新启动它就可以了。似乎存在某种竞争条件,即在 Android Studio 尝试启动 apk 之前模拟器尚未初始化,因此您会收到包错误。

回答by Neelam Prajapati

This Is Worked for me

这对我有用

1)Close Solution.

1)关闭解决方案。

2)Close Emulator.

2)关闭模拟器。

3)Run Emulator and Wait till it launch completely and shows Home Screen.

3)运行模拟器并等待它完全启动并显示主屏幕。

4)After that only Open Solution And Clean,Rebuild and Try to deploy Application.

4)之后只有打开解决方案和清理,重建并尝试部署应用程序。

回答by TheMahd

I had this too, and using this configworked for me :

我也有这个,使用这个配置对我有用:

Device: Nexus One
Target: Android 4.2.2 -api level 17
CPU/ABI: ARM (armeabi-v7a)
Keyboard: Hardware keyboard present

设备:Nexus One
目标:Android 4.2.2 -api level 17
CPU/ABI:ARM (armeabi-v7a)
键盘:存在硬件键盘

Memory Options:

内存选项

RAM: 512
VM Heap: 192
Iternal Storage: 200

RAM:512
VM 堆:192 内部
存储:200

SD Card:

SD卡

Size:200

尺寸:200

回答by Luciano Pinheiro

The same happened to me right now. I don't know if there is another but for me the following worked:

我现在也遇到了同样的情况。我不知道是否还有另一个,但对我来说以下工作:

  • Opened AVD (Android Virtual Device) Manager
  • Started virtual device
  • Hit the Run button again (that one at status bar)
  • 打开 AVD(Android 虚拟设备)管理器
  • 启动虚拟设备
  • 再次点击运行按钮(状态栏上的那个)

Explanation: The problem happened because of timeout. Once device had started, the Android Studio could comunicate with him. (v 0.5.3)

说明:问题是由于超时而发生的。一旦设备启动,Android Studio 就可以与他通信。(v 0.5.3)