11# Python for Android
22
33These instructions are only needed if you're planning to compile Python for
4- Android yourself. Most users should * not* need to do this. If you're looking to
5- use Python on Android, one of the following tools will provide a much more
6- approachable user experience:
7-
8- * [ Briefcase] ( https://briefcase.readthedocs.io ) , from the BeeWare project
9- * [ Buildozer] ( https://buildozer.readthedocs.io ) , from the Kivy project
10- * [ Chaquopy] ( https://chaquo.com/chaquopy/ )
4+ Android yourself. Most users should * not* need to do this. Instead, use one of
5+ the tools listed in ` Doc/using/android.rst ` , which will provide a much easier
6+ experience.
117
128
139## Prerequisites
1410
15- Export the ` ANDROID_HOME ` environment variable to point at your Android SDK. If
16- you don't already have the SDK, here's how to install it:
11+ First, make sure you have all the usual tools and libraries needed to build
12+ Python for your development machine.
13+
14+ Second, you'll need an Android SDK. If you already have the SDK installed,
15+ export the ` ANDROID_HOME ` environment variable to point at its location.
16+ Otherwise, here's how to install it:
1717
1818* Download the "Command line tools" from < https://developer.android.com/studio > .
1919* Create a directory ` android-sdk/cmdline-tools ` , and unzip the command line
@@ -37,11 +37,6 @@ development tools, which currently means Linux or macOS. This involves doing a
3737cross-build where you use a "build" Python (for your development machine) to
3838help produce a "host" Python for Android.
3939
40- First, make sure you have all the usual tools and libraries needed to build
41- Python for your development machine. The only Android tool you need to install
42- is the command line tools package above: the build script will download the
43- rest.
44-
4540The easiest way to do a build is to use the ` android.py ` script. You can either
4641have it perform the entire build process from start to finish in one step, or
4742you can do it in discrete steps that mirror running ` configure ` and ` make ` for
@@ -80,17 +75,20 @@ call. For example, if you want a pydebug build that also caches the results from
8075
8176## Testing
8277
83- The tests can be run on Linux, macOS, or Windows, although on Windows you'll
84- have to build the ` cross-build/HOST ` subdirectory on one of the other platforms
85- and copy it over.
78+ The test suite can be run on Linux, macOS, or Windows:
8679
87- The test suite can usually be run on a device with 2 GB of RAM, though for some
88- configurations or test orders you may need to increase this. As of Android
80+ * On Linux, the emulator needs access to the KVM virtualization interface, and
81+ a DISPLAY environment variable pointing at an X server.
82+ * On Windows, you won't be able to do the build on the same machine, so you'll
83+ have to copy the ` cross-build/HOST ` directory from somewhere else.
84+
85+ The test suite can usually be run on a device with 2 GB of RAM, but this is
86+ borderline, so you may need to increase it to 4 GB. As of Android
8987Studio Koala, 2 GB is the default for all emulators, although the user interface
90- may indicate otherwise. The effective setting is ` hw.ramSize ` in
91- ~ /.android/avd/ * .avd/ hardware-qemu.ini, whereas Android Studio displays the
92- value from config.ini. Changing the value in Android Studio will update both of
93- these files.
88+ may indicate otherwise. Locate the emulator's directory under ` ~/.android/avd ` ,
89+ and find ` hw.ramSize ` in both config.ini and hardware-qemu.ini. Either set these
90+ manually to the same value, or use the Android Studio Device Manager, which will
91+ update both files.
9492
9593Before running the test suite, follow the instructions in the previous section
9694to build the architecture you want to test. Then run the test script in one of
@@ -131,3 +129,8 @@ Every time you run `android.py test`, changes in pure-Python files in the
131129repository's ` Lib ` directory will be picked up immediately. Changes in C files,
132130and architecture-specific files such as sysconfigdata, will not take effect
133131until you re-run ` android.py make-host ` or ` build ` .
132+
133+
134+ ## Using in your own app
135+
136+ See ` Doc/using/android.rst ` .
0 commit comments