简体   繁体   English

如何使用buildozer将软件包导入Kivy应用程序

[英]How can I import an package into a Kivy app using buildozer

I have created a kivy app in package using the structure: 我使用以下结构在软件包中创建了一个kivy应用程序:

.
├── bin
│   └── myapp-0.1-debug.apk
├── buildozer.spec
└── kivy_app
    ├── __init__.py
    ├── __main__.py
    ├── main.py
    └── source
        └── kivy_app.py

I wish to use some features contained in another package that I have written: 我希望使用我编写的另一个软件包中包含的一些功能:

.
└── python_pkg
    ├── __init__.py
    └── source
        └── version.py

The module version.py contains: 模块version.py包含:

VERSION = '0.0.1'

When I insert the line: 当我插入行时:

from python_pkg import VERSION

into kivy_app.py, it works perfectly in kivy on the PC. 进入kivy_app.py,它可以在PC上以kivy完美运行。

I have added python_pkg to the requirements line in buildozer.spec. 我已经在buildozer.spec的要求行中添加了python_pkg。

I can build an APK, but the application will not run on Android. 我可以构建一个APK,但是该应用程序将无法在Android上运行。 The logcat output at the point of failure is: 故障点的logcat输出为:

ImportError: cannot import name 'VERSION' from 'python_pkg' (/data/user/0/org.test.myapp/files/app/_python_bundle/site-packages/python_pkg/__init__.pyc)

The _ init _ .py module in python_pkg has the line: python_pkg中的_ init _ .py模块包含以下行:

from python_pkg.source.version import VERSION

How must arrange the setup up so that it works? 如何安排设置使其起作用?

Thanks to @inclement I have a solution. 感谢@inclement我有一个解决方案。 I have created a symlink to python_pkg and placed it in the kivy_app directory. 我已经创建了一个指向python_pkg的符号链接,并将其放置在kivy_app目录中。 The structure of the application is now 现在应用程序的结构

.
├── bin
│   └── myapp-0.1-debug.apk
├── buildozer.spec
└── kivy_app
    ├── __init__.py
    ├── __main__.py
    ├── main.py
    ├── python_pkg -> /home/jeff/projects/kivy_pkg/python_pkg/python_pkg
    └── source
        └── kivy_app.py

The element python_pkg is not needed in the requirements line in buildozer.spec and I have removed it. buildozer.spec的需求行中不需要python_pkg元素,我已将其删除。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 WSL 中使用 buildozer 创建 kivy android package - creating kivy android package using buildozer in WSL 如何使用 kivy-buildozer 为我的 android 应用程序放置图标? - How to put an icon for my android app using kivy-buildozer? 如何在 ZAEA23489CE3AA9B6406EBB28E0CDA430ozer 上为 ios 编译 python kivy 应用程序 - how to compile python kivy app for ios on Windows 10 using buildozer? 使用 buildozer 在 android 上部署 kivy 应用程序时出错 - Error deploying kivy app on android using buildozer 尝试使用 package 使用 kivy 制作的带有 buildozer 的简单计算器应用程序时出现错误“adb:安装失败” - Error 'adb: failed to install' when trying to package a simple calculator app with buildozer made using kivy 如何在Linux上打包Kivy IOS应用程序? - How can I package a Kivy IOS app while on linux? 如何使用 Kivy 和 buildozer 在 android 中使用 nltk - How to use nltk in android using Kivy and buildozer 使用 Kivy/Buildozer 后,我在 Android 上打开我的应用程序时遇到问题 - I have problems opening my app on Android after using Kivy/Buildozer 我们如何使用 Bluestacks android 仿真器来测试 Kivy app buildozer? - How can we use Bluestacks android emulator for testing Kivy app buildozer? 如何在 Ubuntu 上安装 Buildozer 以创建 Kivy 应用的 Android APK? - How do I install Buildozer on Ubuntu to create an Android APK of a Kivy App?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM