adbutils icon indicating copy to clipboard operation
adbutils copied to clipboard

adb install form URl fails

Open rob-X1 opened this issue 1 year ago • 1 comments

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.

rob-X1 avatar Sep 02 '24 13:09 rob-X1

yes, the logic is contains two steps.

  1. download to pc
  2. push apk from pc to android

codeskyblue avatar Sep 03 '24 06:09 codeskyblue

it should be fine now

codeskyblue avatar Mar 30 '25 12:03 codeskyblue