如何在python中完全制作Android应用程序? [英] How to make Android app completely in python?

查看:1464
本文介绍了如何在python中完全制作Android应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想开发一个(相当简单)的Android应用程序,可以通过Play商店进行分发.我想在python中完全这样做.但是,在线研究并没有启发我:大多数评论要么已经过时(> 1岁,并且我认为此后可能会更好地集成python),或者他们在其中谈论 running python android(例如此处).

I would like to develop a (rather simple) android app to be distributed via Play Store. I would like to do so completely in python. However, the online research hasn't quite enlightened me: most comments are either outdated (>1 year old, and I feel there might be better integration of python since then) or they talk about running python in android (e.g. here).

因此,我正在寻找有关以下问题的信息:

Therefore, I'm looking for information regarding the questions:

  • 完全用python开发应用程序是否可行-这样做的工具是什么? (例如,推荐使用Kivy吗?)
  • 如果是这样的话:什么是最好的软件环境来实现呢? (我尝试使用Android Studio失败,但无法找到一种在其中运行python代码的方法.)

我对应用程序开发非常陌生,并且非常感谢在python中而不是在Jave等中进行此操作的所有线索.

I'm quite new to app development and would highly appreciate any leads of doing this in python rather than in Jave etc., which I don't know yet.

非常感谢您的提前帮助.

Many thanks for you help in advance.

推荐答案

要回答第一个问题:是的,用纯python开发android应用程序是可行的,为此我建议您使用 BeeWare ,它只是 python工具套件,可以很好地协同工作,并且它们使您能够使用python开发平台本机应用程序.

To answer your first question: yes it is feasible to develop an android application in pure python, in order to achieve this I suggest you use BeeWare, which is just a suite of python tools, that work together very well and they enable you to develop platform native applications in python.

checkout 此视频,该视频完美地说明了并演示了应用

checkout this video by the creator of BeeWare that perfectly explains and demonstrates it's application

Android的首选实现语言是Java-因此,如果要用Python编写Android应用程序,则需要一种在Java虚拟机上运行Python代码的方法.这就是 VOC 的作用. VOC 是一个编译器-它需要Python源代码,将其编译为CPython字节码,然后将该字节码转换为Java兼容的字节码.最终结果是将Python源代码文件直接编译为Java .class文件,然后可以将其打包到Android应用程序中.

Android's preferred language of implementation is Java - so if you want to write an Android application in Python, you need to have a way to run your Python code on a Java Virtual Machine. This is what VOC does. VOC is a transpiler - it takes Python source code, compiles it to CPython Bytecode, and then transpiles that bytecode into Java-compatible bytecode. The end result is that your Python source code files are compiled directly to a Java .class file, which can be packaged into an Android application.

VOC还允许您像访问Python对象一样访问本机Java对象,使用Python类实现Java接口,并使用Python类实现Java类的子类.使用此功能,您可以直接针对本机Android API编写Android应用程序.

VOC also allows you to access native Java objects as if they were Python objects, implement Java interfaces with Python classes, and subclass Java classes with Python classes. Using this, you can write an Android application directly against the native Android APIs.

一旦编写了本机Android应用程序,就可以使用公文包进行打包您的Python代码作为Android应用程序.

Once you've written your native Android application, you can use Briefcase to package your Python code as an Android application.

公文包是将Python项目转换为独立的本机应用程序的工具.您可以将项目打包为:

Briefcase is a tool for converting a Python project into a standalone native application. You can package projects for:

  • Mac
  • Windows
  • Linux
  • iPhone/iPad
  • Android
  • AppleTV
  • tvOS.

您可以使用BeeWare套件检查以Python编写的本机Android 井字游戏应用. .在GitHub上

You can check This native Android Tic Tac Toe app written in Python, using the BeeWare suite. on GitHub

除了BeeWare工具外,您还需要安装JDK和Android SDK来测试您的应用程序的运行.

in addition to the BeeWare tools, you'll need to have a JDK and Android SDK installed to test run your application.

并回答第二个问题:好的环境可以是您喜欢的任何内容,无论是文本编辑器,命令行还是IDE,如果您正在寻找好的python IDE,我建议您尝试 Pycharm ,它有一个免费的社区版本,并且由于与Android Studio类似的环境,由同一家公司制造的事实.

and to answer your second question: a good environment can be anything you are comfortable with be it a text editor and a command line, or an IDE, if you're looking for a good python IDE I would suggest you try Pycharm, it has a community edition which is free, and it has a similar environment as android studio, due to to the fact that were made by the same company.

我希望这会有所帮助

这篇关于如何在python中完全制作Android应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆