如何在开发环境中强制安装 Android 应用程序?

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

How to force install of Android App in Development Environment?

android

提问by Code Droid

I'm tired of uninstalling and than reinstalling in development.
Is there a way to do adb -force install some.apk ? I mean this would save a lot of time. Each time going to system ->apps->uninstall every time a signature is different.

我厌倦了卸载而不是在开发中重新安装。
有没有办法 adb -force install some.apk ?我的意思是这会节省很多时间。每次去系统->应用程序->卸载每次签名都不一样。

Obviously debug is a dev setting so I don't see why one constantly needs to uninstall the app manually, what a waste of time? Anything that can make development easier is going to result in better code, and better apps so whats up with this?

显然调试是一种开发设置,所以我不明白为什么人们经常需要手动卸载应用程序,这是在浪费时间吗?任何可以使开发更容易的东西都会产生更好的代码和更好的应用程序,所以这是怎么回事?

I have hot deployed to server side Java EE servers in less time. This is less an issue on command line, since one could do an uninstall or replace the adb script with an uninstall followed by an install.
However in eclipse its still a pain. It has been pointed out that this is largely about signature changes. Yes, it is. But why should signatures change in development, and debug mode, and cause the reinstallation issue?

我已经在更短的时间内热部署到服务器端 Java EE 服务器。这在命令行上不是一个问题,因为可以执行卸载或使用卸载然后安装来替换 adb 脚本。
然而,在eclipse中它仍然很痛苦。有人指出,这主要与签名更改有关。是的。但是为什么签名要在开发和调试模式中改变,并导致重新安装问题?

采纳答案by WarrenFaith

The normal build process uses the android debug keystore that can be found in your android folder in your home directory (path depends on your OS).

正常的构建过程使用可以在主目录的 android 文件夹中找到的 android 调试密钥库(路径取决于您的操作系统)。

With this debug keystore your app will be signed. This debug signature can be installed on every android device in the world as long as there isn't your app with another signature already installed.

使用此调试密钥库,您的应用程序将被签名。只要您的应用程序尚未安装其他签名,就可以在世界上的每台 android 设备上安装此调试签名。

When you say you only do code checkouts, rebuild and your signature is different, than probably your build process is broken. Your debug keystore is valid for at least a year and as long as you are on the same PC while building the generated APK should never have a different signature.

当您说您只进行代码检出、重建并且您的签名不同时,您的构建过程可能已损坏。您的调试密钥库的有效期至少为一年,只要您在构建生成的 APK 时使用同一台 PC 就不应具有不同的签名。

For further checking you should bring some light in your development process. What do you use? Eclipse?

为了进一步检查,您应该在开发过程中有所了解。你用什么?蚀?

If you work on different developing machines, pick one keystore from one machine and put it into your version control and use this to sign your apk with the debug signature.

如果您在不同的开发机器上工作,请从一台机器上选择一个密钥库并将其放入您的版本控制中,并使用它来使用调试签名对您的 apk 进行签名。

回答by Rizky Farhan

adb has [-r] parameter to reinstall.

adb 有 [-r] 参数来重新安装。

adb install -r some.apk

回答by Chris Stratton

A web search you could have done reveals that the answer to your adb question is:

您本可以进行的网络搜索显示您的 adb 问题的答案是:

adb uninstall some.package.name

Note that it's not the file.apk name you use with adb install, but rather the actual package name it ends up installed as.

请注意,这不是用于 adb install 的 file.apk 名称,而是它最终安装的实际包名称。

回答by Vicky Salunkhe

You can install an app forcefully by passing -rparameter.

您可以通过传递-r参数来强制安装应用程序。

-rparameter lets adb to reinstall the app.

-r参数让 adb 重新安装应用程序。

adb install -r app-release.apk

回答by johsin18

The debug keystore can be set in Eclipse in Preferences/Android/Build/Custom debug keystore, which is very helpful when working in a team. Every member should set up the same keystore there, and then it is no problem any longer to share devices.

debug keystore 可以在 Eclipse 中的 Preferences/Android/Build/Custom debug keystore 中设置,这在团队工作时非常有用。每个成员都应该在那里设置相同的密钥库,然后共享设备就没有问题了。

回答by Mohd Saleem

for uninstall adb uninstall app_package_name

卸载 adb 卸载 app_package_name

for install adb install app_package_name

用于安装 adb install app_package_name

into the command prompt in windows and terminal in linex/Macos

进入 windows 中的命令提示符和 linex/Macos 中的终端