在Buildozer.spec文件中添加aiohttp和asyncio依赖,并将这些依赖添加到buildozer.spec文件中requirements字段中,例如:
# Buildozer.spec文件
[app]
....
requirements = python3,kivy, aiohttp, asyncio
在main.py中使用以下代码进行导入:
from kivy.event import EventDispatcher
from kivy.properties import ObjectProperty
import aiofiles
import aiohttp
import asyncio
class MyApp(EventDispatcher):
file_text_input = ObjectProperty()
async def download_file(self, file_url, file_path):
async with aiohttp.ClientSession() as session:
async with session.get(file_url) as response:
async with aiofiles.open(file_path, mode='wb') as f:
await f.write(await response.read())
这样就可以在Buildozer中使用aiofiles了。