Building a development environment for Android apps-creating Android apps in Python

At first

Mainly environment construction and how to use OSS, and almost no implementation of the contents. It is only until you confirm "Start environment construction"-"Created apk works on Android".

Also, mainly Python apps, The procedure for "#Android application development environment construction" and "## Packaging" is the same as for JAVA.

The versions of java and Python are as follows.

Android application development environment construction (JAVA)

First, build an application development environment in JAVA normally. ** But !!! ** I don't bother to write. Things that come out if you google. So only the links I referred to.

Mainly referenced pages

For the problem that came up

Other notes

You should be able to go if you have this area. I took 4-5 hours, but the time I got caught in an error, Excluding various download times, I think it will take about an hour to reach "Hellow, world!" In terms of work content.

Run python

Well, in a sense, this is the main subject.

Convert the script written in Python to apk and run it as an application.

I searched for various things there, and the easiest way is

Use this. As an internal process, it seems that JAVA is kicking Python. .. I haven't followed that far.

SL4A seems to be put together, so there is no need for the user to drop it.

There is a source code on Github, and you can see how to use it by looking at the above Wiki and the Readme on Github.

Code import

The specific procedure I took was First, bring the source to Eclipse.

  1. Download the zip file from "Download ZIP" on the right side of https://github.com/devpack/android-python27
  2. Unzip to a suitable place
  3. Right-click on "Package Explorer" on Eclipse and select "Import".
  4. Select "Existing Android Code Into Workspace" in "Android"
  5. Select the folder (android-python27-master) you just unzipped in the "root directory"
  6. ** Select only this because you don't need anything other than the project name "Python APK" ** (The reason will be described later)
  7. Done

I got this error when I just did this.

Archive for required library: 'libs/armeabi/libcom_googlecode_android_scripting_Exec.so' in project 'PythonAPK' cannot be read or is not a valid ZIP file

It looks like a build path error, I didn't understand it well, so I ignored it in the following procedure.

  1. Right click on the project (Python APK)-> "Properties"
  2. "Java Compiler"-> "Build"
  3. Check "Enable project-specific settings"
  4. Uncheck "Build interruption when build path error occurs" in "Build path problem"
  5. Changed "Incomplete Build Path" level from "Error" to "Warning"
  6. "Apply"-> "OK"

Well, the preparation itself is completed by this point. Other than "Python APK", it seems to be used in the following cases.

I will not use these this time, so I will omit them.

Packaging

Before playing with it, try packaging it in apk once with the default. The result will be the same as the one published below. https://code.google.com/p/android-python27/downloads/detail?name=PythonAPK.apk&can=2&q=

The toast of the message "Hello from Python 2.7 for Android" keeps appearing every 5 seconds.

Even if you say that Python works, the exterior is JAVA, so the method is the same as the JAVA application, see below.

Please delete "android: debuggable =" true "" in "AndroidManifest.xml" before. If it does not appear, the following warning will appear.

Export aborted because fatal lint errors were found. These are listed in the Lint View. Either fix these before running Export again, or turn off "Run full error check when exporting app" in the Android > Lint Error Checking preference page.

After erasing, create an apk by referring to the following. http://blackcapsule.blog107.fc2.com/blog-entry-15.html

So, what I found out here. This apk ... doesn't work with the emulator. .. .. But it works if it is a real record. .. .. 。。。

Well? So let's go next: satisfied:

Easy to use

To write it easily You can move it with ** "Zip and place Python code in a specific place with a specific name" **.

Specifically, there is the following zip file under * "res / raw" * in the project. Maybe each role is also below.

This is the file where "hello.py" in "my_python_project.zip" is running.

In addition, the specification of this file is described in * "src" * * "com.android.python27.config.GlobalConstants.java" *. What each parameter shows

So here's what to do:

  1. Python code creation
  2. Compress the file in zip format
  3. Place the zip file under * "res / raw" *
    • Change the parameters of "com.android.python27.config.GlobalConstants.java" * as appropriate
  4. Package in apk

Python-for-Android (PY4A) is also included, so if it's a simple tool, it may be possible to implement it immediately.

Things I haven't tried yet

I checked the operation by changing the file name. However, I haven't tried adding modules yet. Also, I haven't confirmed the operation on Python3 series. Well, from now on.

That's it.

Recommended Posts

Building a development environment for Android apps-creating Android apps in Python
Building a Python development environment for AI development
[Mac] Building a virtual environment for Python
How about Anaconda for building a machine learning environment in Python?
Development environment in Python
[Python] Web development preparation (building a virtual environment)
Think about building a Python 3 environment in a Mac environment
Building a Python virtual environment
[For organizing] Python development environment
Building a Python virtual environment
Write about building a Python environment for writing Qiita Qiita
Building a Docker working environment for R and Python
Procedure for building a CDK environment on Windows (Python)
Building a Python environment for programming beginners (Mac OS)
Memo for building a machine learning environment using Python
Building a Python environment on Mac
Building a python environment for artificial intelligence (Chainer / TensorFlow / CSLAIER)
Building a Python environment on Ubuntu
Build a Python development environment in Eclipse (add HTML editor)
Building a Hy environment for Lisper who hasn't touched Python
Building a virtual environment with Python 3
[Python] Building a virtual python environment for the pyramid tutorial (summary)
Python development environment options for May 2020
Emacs settings for Python development environment
Until building a Python development environment using pyenv on Ubuntu 20.04
Create a Python environment for professionals in VS Code on Windows
Building a Docker working environment for R and Python 2: Japanese support
Build a local development environment for Lambda + Python using Serverless Framework
Building a Windows 7 environment for getting started with machine learning with Python
From building a Python environment for inexperienced people to Hello world
From installing Ansible to building a Python environment in Vagrant's virtual environment
[Pyenv] Building a python environment with ubuntu 16.04
Building a Python3 environment with Amazon Linux2
Python development environment for macOS using venv 2016
Let's create a virtual environment for Python
Building a Python 3.6 environment with Windows + PowerShell
Get a token for conoha in python
Building a conda environment for ROS users
Creating a development environment for machine learning
Building a virtual environment for Mayavi dedicated to Python 3.6, Anaconda, Spyder users
Prepare Python development environment for each project in Windows environment (VSCode + virtualEnvWrapper + Pylint)
Create a Python development environment locally at the fastest speed (for beginners)
Selenium + WebDriver (Chrome) + Python | Building environment for scraping
Create a Vim + Python test environment in 1 minute
Ubuntu18.04.05 Creating a python virtual environment in LTS
Building an environment for executing Python scripts (for mac)
Building an Anaconda environment for Python with pyenv
Building a Python environment with WLS2 + Anaconda + PyCharm
Create a virtual environment with conda in Python
[Python] Build a Django development environment with Docker
I created a Dockerfile for Django's development environment
Build a Python development environment on your Mac
Commands for creating a python3 environment with virtualenv
Work in a virtual environment with Python virtualenv.
Build a Kubernetes environment for development on Ubuntu
Procedure for creating a Python quarantine environment (venv environment)
Set up a Python development environment on Marvericks
Build a Minecraft plugin development environment in Eclipse
A memo for creating a python environment by a beginner
Building a Python environment on a Sakura VPS server
Build a mruby development environment for ESP32 (Linux)