java Python 在 Android 上的局限性是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11600364/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What are the limitations of Python on Android?
提问by Dave K
I am getting ready to start a little Android development and need to choose a language. I know Python but would have to learn Java. I'd like to know from those of you who are using Python on Android what the limitations are. Also, are there any benefits over Java?
我正准备开始一些 Android 开发,需要选择一种语言。我知道 Python,但必须学习 Java。我想从在 Android 上使用 Python 的人那里知道有哪些限制。另外,与Java相比有什么好处吗?
采纳答案by Andrew Gorcester
I investigated this recently for similar reasons. My conclusions were that I could not use Python to develop a native-looking application, which is what I wanted at the time. Specifically:
我最近出于类似的原因对此进行了调查。我的结论是,我无法使用 Python 来开发外观本机的应用程序,这正是我当时想要的。具体来说:
Python can't receive callbacks from the Java UI classes, so you can't use any native Java UI elements such as ListView, etc. Only dialog boxes etc. are easily available. If you have a totally custom UI such as a game, you can try PyGame for Android, or you could look at Kivy, which also uses PyGame.
Packaging of Python applications is very difficult, especially because the Python interpreter is not included on Android by default. The Kivy and PyGame teams are making some intermittent progress on this.
Because of the aforementioned issues, Python is essentially never used to make full fledged applications published in the app store, and so the literature on how to handle the many sundry issues with SL4A (Scripting Layer For Android) is very thin.
Python 无法接收来自 Java UI 类的回调,因此您无法使用任何原生 Java UI 元素,例如 ListView 等。只有对话框等很容易使用。如果你有一个完全自定义的 UI,比如游戏,你可以试试PyGame for Android,或者你可以看看Kivy,它也使用 PyGame。
Python 应用程序的打包非常困难,特别是因为默认情况下 Android 中不包含 Python 解释器。Kivy 和 PyGame 团队正在这方面取得一些间歇性的进展。
由于上述问题,Python 基本上从未用于制作在应用程序商店中发布的成熟应用程序,因此关于如何使用 SL4A(Android 脚本层)处理许多杂项问题的文献非常少。
So, if you want to make an application that uses native UI elements, that you can actually distribute in the Play Store, or both, Python is regrettably not an option.
所以,如果你想制作一个使用原生 UI 元素的应用程序,你可以在 Play 商店中分发,或者两者兼而有之,遗憾的是 Python 不是一个选择。
回答by qua-non
Most of the points mentioned by Andrew stand, I just wanted to mention that python can be and is used for full fledged Apps published on GooglePlay and even iOS. I can't speak for other frameworks but here are some examples of Apps published using Kivy.
Andrew 提到的大部分观点都站得住脚,我只想提一下,python 可以并且被用于在 GooglePlay 甚至 iOS 上发布的成熟的应用程序。我不能说其他框架,但这里有一些使用 Kivy 发布的应用程序的例子。
- Process Craft Google PlayiOS
- Fantasy War hammer
- PreseMT is a multitouch presentation maker
- Memo robots
- Ground Truth
- Kaleidoscope
- Showcase demo example from Kivy project
- DefelectTouch game iOS
- Bargeniusand many more...
- 工艺工艺Google Play iOS
- 幻想战锤
- PreseMT 是一个多点触控演示制作工具
- 备忘录机器人
- 地面真相
- 万花筒
- 展示来自 Kivy 项目的演示示例
- DefelectTouch 游戏iOS
- Bargenius和更多...
On Packaging we have tried to make it as simple as possible, we also provide
在包装上,我们试图使其尽可能简单,我们还提供
- A pre-built VMthat can be used to make your apk with you having to do nothing except copying your project dir over and running one command.
- 一个预构建的VM,可用于制作您的 apk,除了复制您的项目目录并运行一个命令之外,您无需执行任何操作。
On GUI, yes the ui is custom, by default(tries to match Android's Holo theme). However it can be customised to resemble other look and feels, although I haven't tried it personally.
在 GUI 上,是的,ui 是自定义的,默认情况下(尝试匹配 Android 的 Holo 主题)。但是,它可以自定义为类似于其他外观和感觉,尽管我还没有亲自尝试过。
Oh and as long as one is talking about python based apps on android, I found this project mentioned on stackoverflow PyMob, their appspage mentions some interesting apps .
哦,只要在 android 上谈论基于 python 的应用程序,我发现这个项目在 stackoverflow PyMob上提到,他们的应用程序页面提到了一些有趣的应用程序。
回答by Diamond Dave
I have developed Android Apps on the market, coded in Python. Downsides:
我在市场上开发了 Android 应用程序,用 Python 编码。缺点:
- Thus far my users must download the interpreter as well, but they are immediately prompted to do so. (UPDATE: See comment below.)
- The script does not exit properly, so I include a webView page that asks them to goto:Settings:Apps:ForceClose if this issue occurs.
- 到目前为止,我的用户也必须下载解释器,但会立即提示他们这样做。(更新:见下面的评论。)
- 该脚本未正确退出,因此我包含了一个 webView 页面,如果发生此问题,该页面会要求他们转到:设置:应用程序:ForceClose。