问题
Pixel 3XL could not install app via adb but could using AS run to install the app I use the command line to install the apk and it said it is successfuly. But I could not see the icon in the launcher. Plus, when I try to list the installed apk, it is not in the list.
WM-C02WM0T3HTD8:~ zgong$ adb shell cmd package list packages | grep `common_string_in_package_name_with_installed_app_package`
package:A
package:B
package:C
package:D
WM-C02WM0T3HTD8:~ zgong$ adb install XXXX.apk
Performing Streamed Install
Success
WM-C02WM0T3HTD8:~ zgong$ adb shell cmd package list packages | grep `common_string_in_package_name_with_installed_app_package`
package:A
package:B
package:C
package:D
No new package is installed.
WM-C02WM0T3HTD8:~ zgong$ adb shell cmd package list packages | grep `unique string_in_package_name`
No new package is installed.
It is so weird that this issue happens.
I could use adb to install the apk for other Android device. I am using Android 4.0.1.
Anyone know how to fix it?
Update 1:
The commen says that adb install is the wrapper of adb shell pm install
.
I run the adb shell pm
to get the manual of options.
It seems that there are no options which could help to debug.
WM-C02WM0T3HTD8:android_vdca zgong$ adb shell pm
Package manager (package) commands:
help
Print this help text.
install [-rtfdgw] [-i PACKAGE] [--user USER_ID|all|current]
[-p INHERIT_PACKAGE] [--install-location 0/1/2]
[--install-reason 0/1/2/3/4] [--originating-uri URI]
[--referrer URI] [--abi ABI_NAME] [--force-sdk]
[--preload] [--instant] [--full] [--dont-kill]
[--enable-rollback]
[--force-uuid internal|UUID] [--pkg PACKAGE] [-S BYTES]
[--apex] [--wait TIMEOUT]
[PATH [SPLIT...]|-]
Install an application. Must provide the apk data to install, either as
file path(s) or '-' to read from stdin. Options are:
-R: disallow replacement of existing application
-t: allow test packages
-i: specify package name of installer owning the app
-f: install application on internal flash
-d: allow version code downgrade (debuggable packages only)
-p: partial application install (new split on top of existing pkg)
-g: grant all runtime permissions
-S: size in bytes of package, required for stdin
--user: install under the given user.
--dont-kill: installing a new feature split, don't kill running app
--restrict-permissions: don't whitelist restricted permissions at install
--originating-uri: set URI where app was downloaded from
--referrer: set URI that instigated the install of the app
--pkg: specify expected package name of app being installed
--abi: override the default ABI of the platform
--instant: cause the app to be installed as an ephemeral install app
--full: cause the app to be installed as a non-ephemeral full app
--install-location: force the install location:
0=auto, 1=internal only, 2=prefer external
--install-reason: indicates why the app is being installed:
0=unknown, 1=admin policy, 2=device restore,
3=device setup, 4=user request
--force-uuid: force install on to disk volume with given UUID
--apex: install an .apex file, not an .apk
--wait: when performing staged install, wait TIMEOUT milliseconds
for pre-reboot verification to complete. If TIMEOUT is not
specified it will wait for 60000 milliseconds.
Update 2:
copy the apk to the device:
WM-C02WM0T3HTD8:android_vdca zgong$ adb push ~/Downloads/NonSIMCC-151-app-release-signed.apk /storage/emulated/0/Download/
/Users/zgong/Downloads/NonSIMCC-151-app-release-signed.apk: 1 file pushed. 12.7 MB/s (34493209 bytes in 2.597s)
use pm install
via adb shell
255|crosshatch:/storage/emulated/0/Download $ pm install NonSIMCC-151-app-release-signed.apk
avc: denied { read } for scontext=u:r:system_server:s0 tcontext=u:object_r:fuse:s0 tclass=file permissive=0
System server has no access to read file context u:object_r:fuse:s0 (from path /storage/emulated/0/Download/NonSIMCC-151-app-release-signed.apk, context u:r:system_server:s0)
Error: Unable to open file: NonSIMCC-151-app-release-signed.apk
Consider using a file under /data/local/tmp/
Error: Can't open file: NonSIMCC-151-app-release-signed.apk
Exception occurred while executing 'install':
java.lang.IllegalArgumentException: Error: Can't open file: NonSIMCC-151-app-release-signed.apk
at com.android.server.pm.PackageManagerShellCommand.setParamsSize(PackageManagerShellCommand.java:519)
at com.android.server.pm.PackageManagerShellCommand.doRunInstall(PackageManagerShellCommand.java:1282)
at com.android.server.pm.PackageManagerShellCommand.runInstall(PackageManagerShellCommand.java:1248)
at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:184)
at android.os.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:98)
at android.os.ShellCommand.exec(ShellCommand.java:44)
at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:21605)
at android.os.Binder.shellCommand(Binder.java:929)
at android.os.Binder.onTransact(Binder.java:813)
at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:4603)
at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:4306)
at android.os.Binder.execTransactInternal(Binder.java:1159)
at android.os.Binder.execTransact(Binder.java:1123)
Update 3
crosshatch:/ $ cp /storage/emulated/0/Download/NonSIMCC-151-app-release-signed.apk /data/local/tmp/apk1.apk
\crosshatch:/ $ ls -la /data/local/tmp
total 51656
drwxrwx--x 4 shell shell 3488 2020-11-19 10:13 .
drwxr-x--x 4 root root 3488 2019-11-19 14:53 ..
drwxrwxrwx 4 shell shell 3488 2020-11-10 13:55 .studio
-rw-rw---- 1 shell shell 34493209 2020-11-19 10:13 apk1.apk
-rw-rw-rw- 1 shell shell 4322329 1970-01-01 08:00 apk1592483766800.apk
-rw-rw-rw- 1 shell shell 4808820 1970-01-01 08:00 apk1597806836158.apk
-rw-rw-rw- 1 shell shell 4808820 1970-01-01 08:00 apk1597807282659.apk
-rw-rw-rw- 1 shell shell 4375675 1970-01-01 08:00 apk1599201485983.apk
drwxrwxrwx 5 shell shell 3488 2020-11-02 00:17 perfd
-rw-rw-rw- 1 shell shell 8 1970-01-01 08:00 vysor.pwd
crosshatch:/ $ pm install /data/local/tmp/ap
apk1.apk apk1592483766800.apk apk1597806836158.apk apk1597807282659.apk apk1599201485983.apk
crosshatch:/ $ pm install /data/local/tmp/apk1.apk
Success
crosshatch:/ $ exit
To verify if it is installed for real
WM-C02WM0T3HTD8:android_vdca zgong$ /Users/zgong/Library/Android/sdk/build-tools/29.0.3/aapt2 dump packagename ~/Downloads/NonSIMCC-151-app-release-signed.apk
com.nonsimcc.vmcp
WM-C02WM0T3HTD8:android_vdca zgong$ adb shell cmd package list packages | grep vmcp
It still failed to be installed for real.
Update 4
I have tried to reboot my Pixel 3XL device. Still bad luck.
Update 5
Just tested and the get the weird result:
Android Studio, click Run, and the app could be installed and launched.
WM-C02WM0T3HTD8:mep_login_android zgong$ adb shell cmd package list packages | grep com.visa.mobileEnablement.loginFeatureDemo
package:com.visa.mobileEnablement.loginFeatureDemo
In Run section in Android Studio
11/19 11:51:07: Launching 'demoApp' on Google Pixel 3 XL.
Install successfully finished in 1 s 290 ms.
$ adb shell am start -n "com.visa.mobileEnablement.loginFeatureDemo/com.visa.mobileEnablement.loginFeatureDemo.DemoActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Connected to process 27798 on device 'google-pixel_3_xl-8BBY0WYAG'.
Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
Using the same apk built from Run, and use adb install
WM-C02WM0T3HTD8:mep_login_android zgong$ adb install -t demoApp/build/outputs/apk/classic/debug/demoApp-classic-debug.apk
Performing Streamed Install
Success
WM-C02WM0T3HTD8:mep_login_android zgong$ adb shell cmd package list packages | grep com.visa.mobileEnablement.loginFeatureDemo
What is the difference between adb install
and Android Studio installation process?
Update 6:
Already tried to Revoke USB debugging authorizations Still bad luck.
WM-C02WM0T3HTD8:mep_login_android zgong$ adb install -t demoApp/build/outputs/apk/classic/debug/demoApp-classic-debug.apkPerforming Streamed Install
Success
WM-C02WM0T3HTD8:mep_login_android zgong$ adb shell cmd package list packages | grep com.visa.mobileEnablement.loginFeatureDemo
Also tried to close the Developer options and reopened it. Set the USB Preferences - USE USB FOR, choose PTP or No data transfer. Still bad luck
WM-C02WM0T3HTD8:mep_login_android zgong$ adb install -t demoApp/build/outputs/apk/classic/debug/demoApp-classic-debug.apkPerforming Streamed Install
Success
WM-C02WM0T3HTD8:mep_login_android zgong$ adb shell cmd package list packages | grep com.visa.mobileEnablement.loginFeatureDemo
Update 7:
I noticed that there is an OS update for me to do.
Update 7
"adb install" does not work when installing to the emulator due to unmatching abi
I create a AVD
Name: Pixel_3_XL_API_Q
CPU/ABI: Google APIs Intel Atom (x86)
Path: /Users/zgong/.android/avd/Pixel_3_XL_API_Q.avd
Target: google_apis [Google APIs] (API level Q)
Skin: pixel_3_xl
fastboot.chosenSnapshotFile:
runtime.network.speed: full
hw.accelerometer: yes
hw.device.name: pixel_3_xl
hw.lcd.width: 1440
image.androidVersion.codename: Q
hw.initialOrientation: Portrait
image.androidVersion.api: 28
tag.id: google_apis
hw.mainKeys: no
hw.camera.front: emulated
avd.ini.displayname: Pixel 3 XL API Q
hw.gpu.mode: auto
hw.ramSize: 8192
PlayStore.enabled: false
fastboot.forceColdBoot: no
hw.cpu.ncore: 4
hw.keyboard: yes
hw.sensors.proximity: yes
hw.dPad: no
hw.lcd.height: 2960
vm.heapSize: 4096
skin.dynamic: yes
hw.device.manufacturer: Google
hw.gps: yes
hw.audioInput: yes
image.sysdir.1: system-images/android-Q/google_apis/x86/
showDeviceFrame: yes
hw.camera.back: virtualscene
AvdId: Pixel_3_XL_API_Q
hw.lcd.density: 560
hw.arc: false
hw.device.hash2: MD5:9bbaa408d4a8691920c4057ef7844f35
fastboot.forceChosenSnapshotBoot: no
fastboot.forceFastBoot: yes
hw.trackBall: no
hw.battery: yes
hw.sdCard: no
tag.display: Google APIs
runtime.network.latency: none
disk.dataPartition.size: 40G
hw.sensors.orientation: yes
avd.ini.encoding: UTF-8
hw.gpu.enabled: yes
I tried to install the same apk built from Android Studio.
WM-C02WM0T3HTD8:mep_login_android zgong$ adb -e install -t -r demoApp/build/outputs/apk/classic/debug/demoApp-classic-debug.apk
Performing Streamed Install
adb: failed to install demoApp/build/outputs/apk/classic/debug/demoApp-classic-debug.apk: Failure [INSTALL_FAILED_NO_MATCHING_ABIS: Failed to extract native libraries, res=-113]
Update 8: "adb install" work when installing to another device
So I use the same build to install it on another Pixel 3 device. It can be installed correctly.
WM-C02WM0T3HTD8:mep_login_android zgong$ adb -d install -t demoApp/build/outputs/apk/classic/debug/demoApp-classic-debug.apk
Performing Streamed Install
Success
In this way, we exclude the suspect of the build.
Update 9:
On Pixel 3XL on which it does not work before:
WM-C02WM0T3HTD8:mep_login_android zgong$ /Users/zgong/Library/Android/sdk/build-tools/29.0.3/aapt2 dump packagename demoApp/build/outputs/apk/classic/debug/demoApp-classic-debug.apk
com.visa.mobileEnablement.loginFeatureDemo
WM-C02WM0T3HTD8:mep_login_android zgong$ adb -d uninstall com.visa.mobileEnablement.loginFeatureDemo
Success
WM-C02WM0T3HTD8:mep_login_android zgong$ adb install demoApp/build/outputs/apk/classic/debug/demoApp-classic-debug.apk
error: more than one device/emulator
Performing Push Install
adb: error: failed to get feature set: more than one device/emulator
WM-C02WM0T3HTD8:mep_login_android zgong$ adb -d install demoApp/build/outputs/apk/classic/debug/demoApp-classic-debug.apk
Performing Streamed Install
adb: failed to install demoApp/build/outputs/apk/classic/debug/demoApp-classic-debug.apk: Failure [INSTALL_FAILED_TEST_ONLY: installPackageLI]
WM-C02WM0T3HTD8:mep_login_android zgong$ adb -d install -t demoApp/build/outputs/apk/classic/debug/demoApp-classic-debug.apk
Performing Streamed Install
Success
WM-C02WM0T3HTD8:mep_login_android zgong$ adb shell cmd package list packages | grep visaerror: more than one device/emulator
WM-C02WM0T3HTD8:mep_login_android zgong$ adb -d shell cmd package list packages | grep com.visa.mobileEnablement.loginFeatureDemo
package:com.visa.mobileEnablement.loginFeatureDemo
And now I could see the icon in Launcher and could launch the app. So amazing.
回答1:
It is fixed when uninstalling the apk (adb uninstall
) and then execute the adb install
again
WM-C02WM0T3HTD8:Downloads zgong$ adb -d install ~/Downloads/NonSIMCC-151-app-release-signed.apk
Performing Streamed Install
Success
WM-C02WM0T3HTD8:Downloads zgong$ /Users/zgong/Library/Android/sdk/build-tools/29.0.3/aapt2 dump packagename ~/Downloads/NonSIMCC-151-app-release-signed.apk
com.nonsimcc.vmcp
WM-C02WM0T3HTD8:Downloads zgong$ adb -d shell cmd package list packages | grep com.nonsimcc.vmcp
WM-C02WM0T3HTD8:Downloads zgong$ adb uninstall com.nonsimcc.vmcp
error: more than one device/emulator
- waiting for device -
error: more than one device/emulator
WM-C02WM0T3HTD8:Downloads zgong$ adb -d uninstall com.nonsimcc.vmcp
Success
WM-C02WM0T3HTD8:Downloads zgong$ adb -d shell cmd package list packages | grep com.nonsimcc.vmcp
WM-C02WM0T3HTD8:Downloads zgong$ adb -d install ~/Downloads/NonSIMCC-151-app-release-signed.apk
Performing Streamed Install
Success
WM-C02WM0T3HTD8:Downloads zgong$ adb -d shell cmd package list packages | grep com.nonsimcc.vmcp
package:com.nonsimcc.vmcp
回答2:
Go to build then build bundle(s) / APK(s) then build APK
来源:https://stackoverflow.com/questions/64890875/could-not-really-install-apk-successfully-via-command-line