adbutils
adbutils copied to clipboard
adb install form URl fails
This is a simple example installing a small clock app from F-Droid store downloaded and installed from an URL:
import adbutils
adb = adbutils.AdbClient(host="127.0.0.1", port=5037)
print(adb.device_list())
d = adb.device()
d.install("https://f-droid.org/repo/com.chancehorizon.just24hoursplus_10401.apk")
Based on the log file it seems to download the APK to /data/local/tmp on the Android phone, but when the download has finished it tries to install the APK from a tmp file on the PC:
"C:\Program Files\Python311\python.exe" adb_install.py
[AdbDevice(serial=91121EEHN13855)]
tmpfile path: C:\Users\user\AppData\Local\Temp\tmpvl43azd8.apk
push to /data/local/tmp/tmp-1725282378118.apk
100.0% 4.9 MB/s [2.9 MB/2.9 MB]
100.0% 4.9 MB/s [2.9 MB/2.9 MB]
Traceback (most recent call last):
File "C:\Temp\adb_install.py", line 6, in <module>
d.install("https://f-droid.org/repo/com.chancehorizon.just24hoursplus_10401.apk")
File "C:\Users\user\AppData\Roaming\Python\Python311\site-packages\decorator.py", line 232, in fun
return caller(func, *(extras + args), **kw)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\AppData\Roaming\Python\Python311\site-packages\retry\api.py", line 73, in retry_decorator
return __retry_internal(partial(f, *args, **kwargs), exceptions, tries, delay, max_delay, backoff, jitter,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\AppData\Roaming\Python\Python311\site-packages\retry\api.py", line 33, in __retry_internal
return f()
^^^
File "C:\Users\user\AppData\Roaming\Python\Python311\site-packages\adbutils\install.py", line 90, in install
package_name = apk.manifest.package_name
^^^^^^^^^^^^
File "C:\Users\user\AppData\Roaming\Python\Python311\site-packages\apkutils2\__init__.py", line 211, in manifest
return Manifest(self.get_org_manifest())
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\AppData\Roaming\Python\Python311\site-packages\apkutils2\__init__.py", line 180, in get_org_manifest
self._init_manifest()
File "C:\Users\user\AppData\Roaming\Python\Python311\site-packages\apkutils2\__init__.py", line 215, in _init_manifest
self._init_org_manifest()
File "C:\Users\user\AppData\Roaming\Python\Python311\site-packages\apkutils2\__init__.py", line 202, in _init_org_manifest
raise e
File "C:\Users\user\AppData\Roaming\Python\Python311\site-packages\apkutils2\__init__.py", line 192, in _init_org_manifest
with apkfile.ZipFile(self.apk_path, mode="r") as zf:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\AppData\Roaming\Python\Python311\site-packages\apkutils2\apkfile.py", line 1012, in __init__
self.fp = io.open(file, filemode)
^^^^^^^^^^^^^^^^^^^^^^^
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\user\\AppData\\Local\\Temp\\tmpvl43azd8.apk'
Process finished with exit code 1
Tested on Windows 10 using adbutils 2.8.0.
yes, the logic is contains two steps.
- download to pc
- push apk from pc to android
it should be fine now