How to make kivy urlrequests work with my android apk made in buildozer

181 views
Skip to first unread message

yt

unread,
Sep 26, 2019, 9:32:15 AM9/26/19
to Kivy users support

Im making a moblie app which will use kivy UrlRequests, on ubuntu and macos the app works but when i make a apk with buildozer and run it on my android (OnePlus 5: android 9.0.8) via android studios the application works until the UrlRquest part where it crashes.

Ive made a test apk just to isolate and test the UrlRequest and it works on my pc/laptop and kivy launcher but not as a apk on android.

I also have the buildozer.spec and logcat file let me know if you need

Ive tried and changed the Buildozer.spec permisions and requirements to: android.permissions = INTERNET,ACCESS_NETWORK_STATE

requirements = kivy,android,openssl,pyopenssl,httplib2

I have also tried to change https to http but still no luck

I expect the output to be a value fro btc when the "Make Request" button is pressed, but the actual output is nothing


from kivy.clock              import Clock
from kivy.lang               import Builder
from kivy.network.urlrequest import UrlRequest
from kivy.uix.boxlayout      import BoxLayout


Builder.load_string('''
<DemoLayout>:
  orientation: "vertical"
  padding:     50
  spacing:     50

  Button:
    size_hint: (0.3, 0.3)
    pos_hint:  {"center_x": 0.5}
    text:      "Make Request"
    on_press:  app.make_request()

  Label:
    id: result_label
''')


class DemoLayout(BoxLayout):
  pass


class Demo(App):
  def build(self):
    return DemoLayout()

  def on_request_success(self, request, result):
    self.root.ids.result_label.text = str(result["data"][0]["amount"])

  def make_request(self, *args):
    UrlRequest(
      url         = "https://api.coinbase.com/v2/prices/GBP/spot?",
      on_error    = None,
      on_failure  = None,
      on_progress = None,
      on_redirect = None,
      on_success  = self.on_request_success,
      timeout     = 5,
    )


Demo().run()


buildozer.spec
main (1).py

ZenCODE

unread,
Sep 26, 2019, 3:38:57 PM9/26/19
to Kivy users support
The  best thing to do would be to use buildozer to deploy it on the device and get the logs. It's just guesswork without seeing the actual error, which should be in those logs. The *logcat* command gives you the logs, so your command would be something like
```
buildozer android debug deploy run logcat
```

Robert Flatt

unread,
Sep 26, 2019, 11:05:53 PM9/26/19
to Kivy users support
Search thru these posts
Andrei posted this example a few weeks ago, maybe it will help.....

yt

unread,
Sep 27, 2019, 11:12:06 AM9/27/19
to Kivy users support
Yes i have tried this but it doesnt recognise my device (maybe because im using a virtual machine), so instead ive used android studio on my mac and i have the logcat reports.
Should i attack the output for teh logcat

Robert Flatt

unread,
Sep 27, 2019, 6:13:05 PM9/27/19
to Kivy users support
We don't have any way to know if the Mac emulator and the physical device have the same problem :(

To debug on the physical device connect it to your mac via USB, then execute the adb from Android Studio from a Mac shell prompt.
'adb devices' should show the connected physical device (it will show the emulator if that is running)

'adb' from the virtual machine is, as you point out, unlikely to work, sockets, drivers,.....

I have not done the on a Mac, but it works on Windows (I build on a WSL virtual machine, and debug at a CMD prompt).
On Windows Android Studio adb is at   C:\Users\<USERNAME>\AppData\Local\Android\sdk1\platform-tools\
A little sleuthing you should find the equivalent folder on the Mac.

Andrei Sima

unread,
Sep 30, 2019, 3:43:33 AM9/30/19
to Kivy users support
Hi,

You are trying to hit a https. Guess that on Android something weird is happening.

Please refer to:
and



____________________
Andrei Sima
0723.223.883


--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/1cc404fa-716d-4a31-a92f-e21d0533759d%40googlegroups.com.

Andrei Sima

unread,
Sep 30, 2019, 4:10:58 AM9/30/19
to Kivy users support
As i tried to open the link


The API response is a json file not a json response. In FF and in Chrome.
From Response Headers
content-disposition: attachment; filename=response.json

In AdvancedRestClient it shows the json in response but i guess that app reads the file and displays it.
I have no idea how kv UrlRequest will handle this.




____________________
Andrei Sima
0723.223.883

yt

unread,
Sep 30, 2019, 5:46:13 AM9/30/19
to Kivy users support
I did adb devices on my mac and it outputted "List of devices attached aa78b61 device" i assume that my oneplus, when i unpluged my device and reran the adb devices it outputted "List of devices " and nothign else

yt

unread,
Sep 30, 2019, 5:56:16 AM9/30/19
to Kivy users support
WOW.
Thank you somuch i guess that did teh trick
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages