如何在不使用 Eclipse 的情况下在 Android 上安装/替换

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

How to install/replace on Android without using Eclipse

androidcommand-lineinstallapk

提问by Peter vdL

A buddy sent me a later version of an .apk file. I already had the earlier version on my device.

一个朋友给我发了一个 .apk 文件的更新版本。我的设备上已经有了早期版本。

When I tried to adb install the file, I got this:

当我尝试 adb install 文件时,我得到了这个:

$ adb install ../FlashLite.apk 
320 KB/s (18311 bytes in 0.055s)
    pkg: /data/local/tmp/FlashLite.apk
Failure [INSTALL_FAILED_ALREADY_EXISTS]

$ adb uninstall FlashLite.apk
Failure

$ adb uninstall /data/local/tmp/FlashLite.apk
Failure

How do you install/replace from the cmd line? I don't have the source, so I cannot do it from Eclipse.

您如何从 cmd 行安装/替换?我没有源代码,所以我无法从 Eclipse 中完成。

采纳答案by jqpubliq

delete the old version from your phone under settings->applications->manage applications and then the install should work.

在设置->应用程序->管理应用程序下从手机中删除旧版本,然后安装应该可以工作。

回答by haseman

When you uninstall you have to specify the java path to the activity.

卸载时,您必须指定活动的 java 路径。

adb uninstall com.haseman.myapp

where my main activity is at src/com/haseman/myapp/LaunchActivity.java

我的主要活动在 src/com/haseman/myapp/LaunchActivity.java

further, you can do a replace install with

此外,您可以进行替换安装

adb install -r myApplication.apk

Commonly, however, replacing a build will fail if the same key isn't used to sign both the apk on the phone and the apk you want to install. If you see an error "INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES" you need to uinstall the app first and then install it.

但是,如果手机上的 apk 和要安装的 apk 没有使用相同的密钥签名,则替换构建通常会失败。如果您看到错误“INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES”,您需要先卸载应用程序,然后再安装。

回答by synic

You have to use adb uninstall [packagename], for instance, adb uninstall org.vimtips.supacount.

adb uninstall [packagename]例如,您必须使用adb uninstall org.vimtips.supacount.

This the package name listed in your manifest:

这是清单中列出的包名称:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="org.vimtips.supacount"
    android:versionCode="6" android:versionName="0.1.5">

回答by scepeda

You need to supply the -r key:

您需要提供 -r 键:

adb install -r myapp-release.apk

This has been already discussed: Why does adb install <same-packagename-always-release> fail?

这已经讨论过了: 为什么 adb install <same-packagename-always-release> 失败?

回答by Daniel Benedykt

delete the old version from your phone under settings->applications->manage applications Then you can install by cmd line or upload it to a website and directly download it to the phone

在设置->应用程序->管理应用程序下从手机中删除旧版本然后您可以通过cmd行安装或将其上传到网站并直接下载到手机