Eclipse 和 Android - 安装 APK 时出现问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5227739/
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-09-19 15:56:15  来源:igfitidea点击:

Eclipse and Android - Problem installing APK

javaandroideclipseandroid-emulator

提问by Tim

I'm trying to run the "Hello, World" example found here http://developer.android.com/resources/tutorials/hello-world.htmlI followed the steps exactly, when I launch it I get this output

我正在尝试运行此处找到的“Hello, World”示例http://developer.android.com/resources/tutorials/hello-world.html我完全按照步骤操作,当我启动它时,我得到了这个输出

[2011-03-07 18:34:46 - SDK Manager] Created AVD 'my_avd' based on Android 3.0,
[2011-03-07 18:34:46 - SDK Manager] with the following hardware config:
[2011-03-07 18:34:46 - SDK Manager] hw.lcd.density=160
[2011-03-07 18:34:46 - SDK Manager] hw.keyboard.lid=no
[2011-03-07 18:34:46 - SDK Manager] vm.heapSize=48
[2011-03-07 18:34:46 - SDK Manager] hw.ramSize=256
[2011-03-07 18:34:51 - HelloAndroid] ------------------------------
[2011-03-07 18:34:51 - HelloAndroid] Android Launch!
[2011-03-07 18:34:51 - HelloAndroid] adb is running normally.
[2011-03-07 18:34:51 - HelloAndroid] Performing com.example.helloandroid.HelloAndroid      activity launch
[2011-03-07 18:34:51 - HelloAndroid] Automatic Target Mode: launching new emulator with compatible AVD 'my_avd'
[2011-03-07 18:34:51 - HelloAndroid] Launching a new emulator with Virtual Device 'my_avd'
[2011-03-07 18:34:55 - Emulator] emulator: emulator window was out of view and was recentred
[2011-03-07 18:34:55 - Emulator] 
[2011-03-07 18:34:56 - HelloAndroid] New emulator found: emulator-5554
[2011-03-07 18:34:56 - HelloAndroid] Waiting for HOME ('android.process.acore') to be launched...
[2011-03-07 18:54:55 - HelloAndroid] HOME is up on device 'emulator-5554'
[2011-03-07 18:54:55 - HelloAndroid] Uploading HelloAndroid.apk onto device 'emulator-5554'
[2011-03-07 18:54:55 - HelloAndroid] Installing HelloAndroid.apk...
[2011-03-07 18:57:52 - HelloAndroid] Failed to install HelloAndroid.apk on device  'emulator- 5554!
[2011-03-07 18:57:52 - HelloAndroid] (null)
[2011-03-07 18:57:54 - HelloAndroid] Launch canceled!

A fullscreen window opens up with blinking "Android" text, after a very long time it boots into the emulator. However it doesn't display the Hello World program.

一个全屏窗口打开并显示闪烁的“Android”文本,很长一段时间后它会启动到模拟器中。但是它不显示 Hello World 程序。

My questions 1) How do I run my program? 2) Is there any faster way to sped up the emulator? I don't want to wait everytime I need to run the program

我的问题 1) 我如何运行我的程序?2)有没有更快的方法来加速模拟器?我不想每次需要运行程序时都等待

Thank you for the help.

感谢您的帮助。

Edit: I'm on Ubuntu 10.04 and Eclipse Galileo

编辑:我在 Ubuntu 10.04 和 Eclipse Galileo

回答by stacker

You need to increase the ADB connection time out. It defaults to 5 seconds which is too short for the big app. You find the dialog Menu: Windows -> Preferences -> Android.

您需要增加 ADB 连接超时。它默认为 5 秒,这对于大型应用程序来说太短了。您会找到对话框菜单:Windows -> 首选项 -> Android。

enter image description here

在此处输入图片说明

回答by providence

This has happened to me in the past, it was solved by simply attempting the install again once the emulator was booted up properly. Give that a shot. If that doesn't work:

这在过去发生在我身上,一旦模拟器正确启动,只需再次尝试安装即可解决。试一试。如果这不起作用:

  1. Ensure the emulator you've created is equal to the targeted sdk you've set for the app.
  2. Look for any null pointers in the app, maybe a typo?
  3. Ensure that the emulator supports all the features you require in the application (probably not the case with hello world)
  4. try a clean + re-build of the app, then try to install it once you've done that.
  1. 确保您创建的模拟器与您为应用程序设置的目标 SDK 相同。
  2. 在应用程序中查找任何空指针,也许是错字?
  3. 确保模拟器支持您在应用程序中需要的所有功能(可能不是 hello world 的情况)
  4. 尝试干净+重新构建应用程序,然后在完成后尝试安装它。

回答by Xezuka

I ran into this issue multiple times and have solved it 99% of the time by running the Emulator and letting it get stable -- once it was stable I clicked 'Run' again -- SUCCESS!

我多次遇到这个问题,通过运行模拟器并让它稳定下来,99% 的时间都解决了这个问题——一旦稳定下来,我再次点击“运行”——成功!

If you're still having issues, check what programs are currently running in your computer's background. When an install failed, I exited PowerISO which I had running, tried again, and it installed successfully!

如果仍有问题,请检查当前在计算机后台运行的程序。当安装失败时,我退出了我正在运行的 PowerISO,再试一次,它安装成功!

Good luck! =)

祝你好运!=)

回答by Rich Ramos

I'm also new to android and I'm still running into into this problem (running SDK 3, Version: 10.0.0.v201102162101-104271). I've tried this procedure with mixed results: Eclipse isn't talking to the emulator FAQ. It's not clear to me whether or not it's OK to have multiple copies of an app on the (emulator?) target. I wouldn't think so but, while I have seen this output in my /data/app directory (see below) it's possible that was a transient state.

我也是 android 的新手,我仍然遇到这个问题(运行 SDK 3,版本:10.0.0.v201102162101-104271)。我已经尝试过这个过程,但结果喜忧参半:Eclipse 没有与模拟器 FAQ 对话。我不清楚在(模拟器?)目标上有多个应用程序副本是否可以。我不这么认为,但是,虽然我在 /data/app 目录(见下文)中看到了这个输出,但它可能是一个瞬态状态。

root@android:/data/app # ls
ls
ApiDemos.apk
CubeLiveWallpapers.apk
GestureBuilder.apk
SoftKeyboard.apk
WidgetPreview.apk
com.example.helloandroid-1.apk
com.example.helloandroid-2.apk
vmdl-206041726.tmp
root@android:/data/app # ls
ls
ApiDemos.apk
CubeLiveWallpapers.apk
GestureBuilder.apk
SoftKeyboard.apk
WidgetPreview.apk
com.example.helloandroid-1.apk
com.example.helloandroid-2.apk
vmdl-206041726.tmp

I think that, by observing the logcat output, most of the times that I've seen that failure there was a failure to uninstall the older version of the app. But, being a newbee, I can't be sure.

我认为,通过观察 logcat 输出,我看到失败的大部分时间是无法卸载旧版本的应用程序。但是,作为新手,我不能确定。

I read that you can go into the /data/app directory (run 'adb shell' then 'cd /data/app') and delete the ...helloandroid-x.apk file before attempting to install the new apk. I haven't tried that approach yet.

我读到您可以进入 /data/app 目录(运行 'adb shell' 然后运行 ​​'cd /data/app')并在尝试安装新的 apk 之前删除 ...helloandroid-x.apk 文件。我还没有尝试过这种方法。

Finally you can uninstall using this approach: adb uninstall com.example.helloandroid

最后你可以使用这种方法卸载: adb uninstall com.example.helloandroid

If this helps you'll be luck not to run into the problem I'm having now, which is: I can't get the app to start from eclipse so I can't debug/step through code.

如果这对您有帮助,您将很幸运不会遇到我现在遇到的问题,即:我无法从 Eclipse 启动应用程序,因此我无法调试/单步执行代码。

回答by Lukas Knuth

This seams to be a common problem since there are more then 100 posts out there (which I found on Googles first site) which cover this problem.

这似乎是一个常见问题,因为有超过 100 篇帖子(我在 Google 的第一个网站上找到)涵盖了这个问题。

It seams that this is just something that you can't really answer because it seams that there is an individual solution to this problem. See the previous questions:

这似乎是您无法真正回答的问题,因为它似乎有针对此问题的单独解决方案。看前面的问题:

Also, there seams to be another working solutionout there (at least for some people).

此外,还有另一种可行的解决方案(至少对某些人而言)。