Today, when I used the adb command to install apk, it was unable to install successfully. I also couldn't install successfully when I entered platform_tools under Android sdk:
Let me post my calling process first
xu:~ xiaokai$ adb devices List of devices attached 0123456789ABCDEF device xu:~ xiaokai$ adb shell shell@T36DH_CM3:/ $ pm install /Users/xiaokai/Downloads/ pkg: /Users/xiaokai/Downloads/ Failure [INSTALL_FAILED_INVALID_URI] 1|shell@T36DH_CM3:/ $ adb install /Users/xiaokai/Downloads/ Invalid APK file: /Users/xiaokai/Downloads/ 255|shell@T36DH_CM3:/ $ exit xu:~ xiaokai$ adb install /Users/xiaokai/Downloads/ [100%] /data/local/tmp/ pkg: /data/local/tmp/ Success
adb devices
First, adb devices are called to check if there is any available mobile phone. `0123456789ABCDEF device` indicates that there is an available mobile phone.
adb shell
Then enter the phone, install the apk,
pm install /Users/xiaokai/Downloads/
I found a problem,
exit
Before exiting the phone, enter the root directory
adb install /Users/xiaokai/Downloads/
After the installation, I found that the installation was successful. I checked it online. The following article introduces some problems in this area.
Supplement to the above article:adb installation apk error Failure [INSTALL_FAILED_INVALID_URI]
Today, when I installed an apk using the adb command, I encountered a problem, and the records are as follows:
1. Download one and put it in the D:\A_Download directory.
2. Connect your phone to the computer and enable USB debugging permissions. Then start cmd on the computer and enter the following command:
C:\Users\leon>adb devices List of devices attached 0123456789ABCDEF device
It can be seen that the phone has been successfully connected.
3. Enter the adb shell command to enter shell mode. Then use the install command to install the above apk file. But the prompt failed:
C:\Users\leon>adb shell shell@android:/ $ install D:\A_Download\ BusyBox v1.20.2-jb bionic (2012-11-25 17:47 +0100) multi-call binary. Usage: install [-cdDsp] [-o USER] [-g GRP] [-m MODE] [SOURCE]... DEST Copy files and set attributes -c Just copy (default) -d Create directories -D Create leading target directories -s Strip symbol table -p Preserve date -o USER Set ownership -g GRP Set group ownership -m MODE Set permissions
After analyzing, it turned out that I forgot to use the pm prefix (for analysis of the install command to add pm prefix, please refer to another article:Detailed explanation of the function and usage of pm tools in Android adb command). So modify the command:
shell@android:/ $ pm install D:\A_Download\ pkg: D:A_Downloaddemo.apk Failure [INSTALL_FAILED_INVALID_URI]
Still prompted to fail!
After repeated analysis, I think it should be because the Windows directory information cannot be recognized under the adb command. That is to say, the adb command cannot recognize the "D:\A_Download\" directory here. It is also because of this that the reason it gives is INVALID_URI.
In order to solve this problem, the solution is actually very simple, just exit the adb shell environment. So I entered the exit command and fell back to the Windows cmd environment, and then used the adb install command, and it was indeed successful.
shell@android:/ $ exit C:\Users\leon>adb install D:\A_Download\ [100%] /data/local/tmp/ pkg: /data/local/tmp/ Success
Of course, the above ideas are just what I take for granted, and I must verify whether this is the case. How to verify it?
As mentioned above, according to my guess, the reason why the above installation method fails is because the adb environment cannot recognize the directory format of the Windows system. Therefore, if we copy the file to the phone in advance, then enter the adb shell environment and install, and avoid the shell environment to recognize the windows directory format, we should be successful.
So, I directly pushed the apk file into my phone in the cmd environment, then entered the adb shell environment, and ran the pm install command, and it was indeed successful!
C:\Users\leon>adb push D:\A_Download\ sdcard/ [100%] sdcard/ C:\Users\leon>adb shell shell@android:/ $ cd sdcard/ shell@android:/sdcard $ pm install pkg: Success
So, in a word, in the adb shell environment, the system cannot recognize the directory format of Windows, either return to the cmd environment, or copy the Windows file to the phone in advance. Similar problems will not happen again!
Get it done, finish the work!
The above question that prompts Invalid APK file when installing apk on Android adb is all the content I share with you. I hope you can give you a reference and I hope you support me more.