Solved -  Install extern APK from python code in Leia
#1
Hello friends.

I have a problem and I do not know if it is a bug of Kodi 18 RC4 or is that now it can not be done this way.

I mean, I had made an addon that downloads and installs RetroArch. In Krypton it worked perfectly. But I've been testing Kodi 18 Leia.

And although the download continues to work perfectly, when I try to install the APK I get an exception, but it does not give any information in the log.

The python command that I use is:

xbmc.executebuiltin ('StartAndroidActivity ("", "android.intent.action.VIEW", "application / vnd.android.package-archive", "file:' + pathdownload + '")')

And pathdownload is correct, it points directly to the RetroArch APK. As I say, Krypton works perfectly; but in Leia, looking at the log, this error appears:

16: 49: 11.528 T: 534199280720 INFO: CPythonInvoker (1, /storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/script.insretroarch/default.py): script successfully run
16: 49: 11.528 T: 534199280720 DEBUG: onExecutionDone (1, /storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/script.insretroarch/default.py)
16: 49: 11.546 T: 534392075344 ERROR: CXBMCApp :: StartActivity - ExceptionOccurred launching
16: 49: 11604 T: 534199280720 INFO: Python interpreter stopped
16: 49: 11604 T: 534199280720 DEBUG: Thread LanguageInvoker 534199280720 terminating
16: 49: 11.612 T: 534200317008 ERROR: GetDirectory - Error getting plugin: //script.insretroarch/
16: 49: 11.613 T: 534200317008 DEBUG: Thread waiting 534200317008 terminating
16: 49: 11.627 T: 534392075344 DEBUG: ------ Window Deinit (DialogBusy.xml) ------
16: 49: 11.627 T: 534392075344 ERROR: CGUIMediaWindow :: GetDirectory (plugin: //script.insretroarch/) failed
16: 49: 11.627 T: 534392075344 DEBUG: CGUIMediaWindow :: GetDirectory () 16: 49: 11.628 T: 534392075344 DEBUG: ParentPath = [plugin: //script.insretroarch/]

If you need the source code of the addon or a more extensive log, just tell me. Thanks for your help.
Reply
#2
Hello again, friends.

Finally, I have managed to do it, but making a direct call to the am command (Android Manager).

Thank you very much.
Reply
#3
Thread marked solved.
Got a Kodi problem? Provide us with a full Debug log (wiki) || Usefull pages: First time user (wiki) || Troubleshooting (wiki) || Free content (wiki) || Forum rules (wiki) || VPN policy (wiki)
Reply
#4
(2019-01-15, 15:46)lunamoon Wrote: Hello again, friends.

Finally, I have managed to do it, but making a direct call to the am command (Android Manager).

Thank you very much.

Are you referring to adb? Can you post an example of the Android Manager call?; thanks...
Image Lunatixz - Kodi / Beta repository
Image PseudoTV - Forum | Website | Youtube | Twitter
Reply
#5
Hi, Lunatixz.

I did not want to use adb so I did not have to install it. And sorry, because I was wrong in my previous post, I don't use am to install an APK.
I use Package Manager (pm) to install an APK and am command to launch an APK.

So I tried directly with a call to the pm command, using subprocess.call first and in case it fails, a direct call to os.system.

So, I made a function like this:

def launch_command(command_launch):
    try:
        xbmc.log('[%s] %s' % ('LAUNCHING SUBPROCESS:', command_launch), 2)
        external_command = subprocess.call(command_launch, shell = True, executable = '/system/bin/sh')
    except Exception, e:
        try:
            xbmc.log('[%s] %s' % ('ERROR LAUNCHING COMMAND !!!', e.message, external_command), 2)
            xbmc.log('[%s] %s' % ('LAUNCHING OS:', command_launch), 2)
            external_command = os.system(command_launch)
            xbmc.sleep(500)
        except:
            xbmc.log('[%s] %s' % ('ERROR LAUNCHING COMMAND !!!', e.message, external_command), 2)

And parameter to launch_command function could be like this:

pm install -r -g -d path_to_apk

Greetings.
Reply
 
Thread Rating:
  • 0 Vote(s) - 0 Average



Logout Mark Read Team Forum Stats Members Help
Install extern APK from python code in Leia00