Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
658 views
in Technique[技术] by (71.8m points)

apk - Android ADB shell: Enable USB app installation

I have a question about APK installation internals.

If you want to install an APK on some Android devices via ADB (adb install APK.apk or pm install /data/local/tmp/APK.apk) you have to enable USB installation in Developer Options. If the USB installation is not enabled, you'll be presented an error on installation, most likely something like

adb: failed to install app.apk: Failure [INSTALL_FAILED_USER_RESTRICTED: Installation blocked]

My questions are:

  • How is enabling/disabling of the USB installation implemented in the system? At what point does the error above occur?
  • Is there a way how to enable USB app installation via ADB? I know I could write a script that calls input tap X Y or similar GUI commands, but that's not what I want. What I'd like to know is whether there is an entirely non-GUI way of doing this, something like setprop install.via.usb 1 or echo 1 > /system/etc/install_via_usb

I'm interested in ways to do this for both rooted and unrooted devices.

question from:https://stackoverflow.com/questions/66065683/android-adb-shell-enable-usb-app-installation

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I had the same issue a few weeks ago, the problem was in my AndroidManifest.xml because I included a which internally didn't allow my phyisical device to install the APK (never knew why) so I had to remove it and then it worked

In this case that's what solved it, but I don't know if you're facing the same issue.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...