📜 ⬆️ ⬇️

Automate the installation of many apk files on Android

Have you ever encountered a situation when you need to automate the installation of a certain list of applications on an Android device? You may have such a question if you have many devices and you need to install the same programs for everything. Or in a situation if you frequently reflash your smartphone with different firmware and want to immediately have certain applications on board for work.
How can this be done? You cannot do this in the official Google Play store. There is a category "My Applications", in which two tabs: "installed" and "all" (which have ever been installed and then deleted). There is also a category "Wish list". But nowhere is there a button for setting the entire list of desires, and nowhere is the “Favorites” list.
Thus, on Google Play to install the desired list of programs, you will have to patiently and long choose one application from your list and press the install button on each one. This option does not suit us.


Method with local storage of apk files


The next option: we will try to download all the applications as apk files and install them. The advantage of this method is that you don’t have to depend on Google Play and are afraid that some application will be deleted there. You can also put your own applications that are not in Google Play.
This is where the fun begins. How to download from Google Play? It’s just not possible to extract the apk file from it. Play.google.com simply does not have a “Download” button. There is only "install" (and then only in the case of "compatibility" with the device) and "add to the wish list." Secondly, on the phone we can not see the applications that interest us. Those that are "incompatible" with your device, simply do not appear, as if they are not. The word "Incompatible" in quotes - because in fact the application may well be compatible. This artificial restriction on the installation is done for obvious reasons - limiting oneself from negative feedback and compliance with local laws, or the desire to give access to the application only to a certain “ite”. The incompatibility can be affected by the name of the phone manufacturer, the screen resolution, the country of residence, the mobile operator, the frequency and architecture of the processor, and so on (there are programs to replace all of this). And, apparently, so you can not just go and download apk c Google play. This service wants to know for which particular device and account the application is downloaded and give the necessary apk to it.

So how do you download it?


Googling the problem, I found an online service like APK downloader (http://apps.evozi.com/apk-downloader/). You give a link to the application on the site play.google.com and get a direct link to apk. However, this service cannot be downloaded from Samsung Apps.
We download everything we need. Now we connect the device, turn on usb debugging and install all applications with the script. About this script:
# / bin / sh
for i in {1..50}
do
adb install apk $ i.apk
done
Everything. Now all applications are installed.
This decision is not very beautiful. At any time, APK Downloader can be covered. And in general for me this service is like a black box. I do not know how he shakes. By the way, the same Apk downloader is available as an unofficial chrome extension (crx). This is a zip archive with files. I plan to watch the source from it. Maybe I know how the jump is initialized. Here it is: codekiem.com/apk-downloader/crx/1.2.crx
I guess that the only way to download from the device is downloading to some device. This service probably downloads it like this: it extracts the file from the “device memory”, and then it gives the already downloaded apk. Why then he also did not make the jump with the Samsung Aps?
')

How to deal with updates


There is still a problem with updates. How can I update applications in my repository? All re swing? There is no convenient viewing of the package version and automatic update in general. But there is one software that can solve all these problems. True, I did not try to make it. It is called Real apk leecher. The author posted the source code on xda developers.
Here w3bsit3-dns.com.ru/forum/index.php?showtopic=384677&st=60#entry16248359 instructions on how to update the local storage.

Method without local storage of apk files


I would like to be able to install not only from my storage, but directly from Google. This solves the problem of older versions of applications. How to do it programmatically, I do not know.
To install apk on the device, you can use the following commands:
$ adb install <path to apk on computer>
or
$ adb shell pm install [options] <path to apk on phone>

Please note that on Google Play on your computer there is a “install” button under the application. Gaining on it leads to reading permissions and confirming the desire of the installation. Further, on the phone connected to the Internet [I CAN NOT EVER ATTEND IT AT ALL,] the apk itself comes and is installed. That is, it is enough to send some command from the Internet to the phone and he will do everything. It gives some hope. Similarly, with the button you can install the application from Samsung Apps.
I guess that the market holders (Google and Samsung) have left for themselves the ability to connect to the root shell. When you click the "install" button on the site they do

$ adb push <apk file from their repository> <temporary folder on your android>

Then

$ adb shell pm install <path to the apk file just downloaded>.

Then throw in the notification "successfully installed." Or some similar scheme. So it turns the installation from the computer.
The problem then is how to find out which team and how to send it to the phone so that he downloads everything and installs from their repository ? They certainly ask the phone about its serial, the version of the program already installed. Maybe you need to pre-install a sniffer and listen on all traffic, between the body and the Internet. But I do not know how to do it. Experienced habrovchane prompt?

Related Links:
toster.ru/q/62556
W3bsit3-dns.com/forum/index.php?showtopic=345461
androidsmartfony.com/249-kak-ustanovit-mnogo-apk-faylov-na-android-ustroystvo-s-pk-v-odin-klik.html
www.linux.org.ru/forum/mobile/7535268
W3bsit3-dns.com/forum/index.php?showtopic=316475&st=740

Source: https://habr.com/ru/post/215591/


All Articles