如何使 kivy urlrequests 与我在 buildozer 中制作的 android apk 一起工作
How to make kivy urlrequests work with my android apk made in buildozer
我正在制作一个将使用 kivy UrlRequests 的移动应用程序,在 ubuntu 和 macOS 上该应用程序可以运行,但是当我使用 buildozer 制作一个 apk 并在我的 android 上 运行 ( OnePlus 5:android 9.0.8) 通过 android studios 应用程序一直运行到崩溃的 UrlRquest 部分。
我制作了一个测试 apk,只是为了隔离和测试 UrlRequest,它可以在我的 pc/laptop 和 kivy 启动器上运行,但不能作为 android 上的 apk。
我还有 buildozer.spec 和 logcat 文件,如果您需要,请告诉我
我已尝试将 Buildozer.spec 权限和要求更改为:
android.permissions = INTERNET,ACCESS_NETWORK_STATE
requirements = kivy,android,openssl,pyopenssl,httplib2
我也试过把 https 改成 http 还是不行
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()
我希望当按下 "Make Request" 按钮时输出是 btc 的值,但实际输出什么都没有
我在 http://www.jiajianhudong.com/question/3324796.html 找到了解决方案
我更新了我的 buildozer 要求以添加 certfi
并将 ca_file=certifi.where()
参数添加到我的 UrlRequest()
我正在制作一个将使用 kivy UrlRequests 的移动应用程序,在 ubuntu 和 macOS 上该应用程序可以运行,但是当我使用 buildozer 制作一个 apk 并在我的 android 上 运行 ( OnePlus 5:android 9.0.8) 通过 android studios 应用程序一直运行到崩溃的 UrlRquest 部分。
我制作了一个测试 apk,只是为了隔离和测试 UrlRequest,它可以在我的 pc/laptop 和 kivy 启动器上运行,但不能作为 android 上的 apk。
我还有 buildozer.spec 和 logcat 文件,如果您需要,请告诉我
我已尝试将 Buildozer.spec 权限和要求更改为:
android.permissions = INTERNET,ACCESS_NETWORK_STATE
requirements = kivy,android,openssl,pyopenssl,httplib2
我也试过把 https 改成 http 还是不行
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()
我希望当按下 "Make Request" 按钮时输出是 btc 的值,但实际输出什么都没有
我在 http://www.jiajianhudong.com/question/3324796.html 找到了解决方案
我更新了我的 buildozer 要求以添加 certfi
并将 ca_file=certifi.where()
参数添加到我的 UrlRequest()