前言
多数情况下,用户都是从应用商店或某网页下载apk后从手机上直接安装apk文件,在调试或下载到电脑上时候,我们就可以直接通过adb安装到手机。在测试小伙伴测试过程中也可能直接收到开发小伙伴直接发来的apk,有些小伙伴通过电脑微信或qq传递手机微信或手机qq后安装,此外也可以通过adb 直接安装。
Android adb 启动APP Android代码安装apk程序
ADB简单介绍
adb 是Android 开发调试工具,在…\Android\Sdk\platform-tools目录中 单独下载sdk解压或安装就可以得到,我们在环境变量中添加…\Android\Sdk\platform-tools后,在命令行窗口就可以使用 adb 命令了。没添加环境变量需要把整个路径带上。
安装命令
adb install -r app.apk 覆盖安装的话最好都带上-r,不是覆盖可以不用带-r
操作:
- win + r 或直接打开运行,输入cmd
- 输入adb install 然后将apk文件拖入命令行窗口,回车
- 安装成功
安装失败情况
- 签名不一致,由于debug和release使用的签名不一致,这种情况下,可以先卸载已安装的版本,可手动卸载或 adb 卸载
adb uninstall 包名 - 有些手机需要在安装过程在手机上确认安装(小米系列)
- 开启调试模式
设置-系统-开放人员选项-开启开放人员选项和usb调试
adb 安装卸载的所有命令摘要
install [-lrtsdg] [--instant] PACKAGE
push a single package to the device and install it
install-multiple [-lrtsdpg] [--instant] PACKAGE...
push multiple APKs to the device for a single package and install them
install-multi-package [-lrtsdpg] [--instant] PACKAGE...
push one or more packages to the device and install them atomically
-r: replace existing application
-t: allow test packages
-d: allow version code downgrade (debuggable packages only)
-p: partial application install (install-multiple only)
-g: grant all runtime permissions
--abi ABI: override platform\'s default ABI
--instant: cause the app to be installed as an ephemeral install app
--no-streaming: always push APK to device and invoke Package Manager as separate steps
--streaming: force streaming APK directly into Package Manager
--fastdeploy: use fast deploy
--no-fastdeploy: prevent use of fast deploy
--force-agent: force update of deployment agent when using fast deploy
--date-check-agent: update deployment agent when local version is newer and using fast deploy
--version-check-agent: update deployment agent when local version has different version code and using fast deploy
(See also `adb shell pm help` for more options.)
uninstall [-k] PACKAGE
remove this app package from the device
'-k': keep the data and cache directories
|