[PYTHON] Kivy-Android Memo (MAC)

Reference site

1. Preparation

-Enable to build Kivy-ios memo (MAC). -Download and install JAVA6 from Apple's site.

2. Install required modules

console


pip install buildozer

3. Build

-Copy the touchtracer of the sample program attached to kivy to an appropriate directory.

console


 cd touchtracer
 buildozer init

-A file called buildozer.spec will be generated, so set the necessary information. Buildozer automatically downloads the required modules. If you need a specific SDK or NDK, set the API version etc. in this file.

buildozer.spec



# (str) Title of your application
title = Touchtracer  ###Application title name

# (str) Package name
package.name = Touchtracer  ###Application package name

# (str) Package domain (needed for android/ios packaging)
package.domain = com.domain  ###Application domain name
…
…
…
# (list) Source files to include (let empty to include all the files)
source.include_exts = py,png,jpg,kv,atlas  ###Add required file name extension
…
…
…
# (str) Application versioning (method 1)
#version.regex = __version__ = ['"](.*)['"]
#version.filename = %(source.dir)s/main.py ###Comment if the version is not described in the file

# (str) Application versioning (method 2)
version = 0.1.0  ###If the version is not described in the file, uncomment and set the version

# (list) Application requirements
# comma seperated e.g. requirements = sqlite3,kivy
requirements = kivy  ###Set the required module name additionally
…
…
…
# (str) Presplash of the application
presplash.filename = %(source.dir)s/png/landscape.png  ###Specify the image of the splash screen*/

# (str) Icon of the application
icon.filename = %(source.dir)s/png/76pt_x2.png  ###Specify icon image
…
…
…

# (list) Permissions
android.permissions = INTERNET,WRITE_EXTERNAL_STORAGE  ###Set required permissions etc.
…
…
…
# (list) python-for-android whitelist
android.p4a_whitelist = lib-dynload/*codec*,encodings/cp*.pyo,encodings/tis*,encodings/shift*,encodings/bz2*,encodings/iso*,encodings/undefined*,encodings/johab*,encodings/p*,encodings/m*,encodings/euc*,encodings/k*,encodings/unicode_internal*,encodings/quo*,encodings/gb*,encodings/big5*,encodings/hp*,encodings/hz*   ###Enable CODEC for character conversion

-Generate a debug version package (generated under BIN in the current directory)

console


 buildozer android debug

-Generate a debug version package while displaying BUILDLOG on the screen (generated under BIN in the current directory)

console


buildozer --verbose android debug

-Generation of release version (generated under BIN in the current directory)

console


 buildozer android release

4. Signing the release version

-The release version cannot be installed without a signature, so you need to sign it. If you have a formal certificate, use it, if not, generate an appropriate certificate (if you want to install and run it for the time being).

console


jarsigner -keystore keystorename -verbose touchtracer-1.2.0.apk touchtracer

5. Full screen support

To turn off the navigation bar, add the code below. However, at the moment, when the on-screen keyboard is displayed, the navigate button is displayed.

・ Modified to spec file

buildozer.spec


# (int) Minimum API required (8 = Android 2.2 devices)
android.minapi = 19

-Kivy-Modified Android source (onResume location)

java:.buildozer/android/platform/python-for-android/src/src/org/renpy/android/PythonActivity.java



   @Override
    protected void onResume() {
        super.onResume();
        _isPaused = false;

        if (!mLaunchedThread) {
            mLaunchedThread = true;
            new Thread(this).start();
        }
        
		 /// ADD for HIDE NAVIGATEBAR must above API19 ///
        try {
            this.mInfo = this.getPackageManager().getApplicationInfo(
                    this.getPackageName(), PackageManager.GET_META_DATA);
            Log.v("python", "metadata fullscreen is" + this.mInfo.metaData.get("fullscreen") + " For HIDE_NAVIGATIONBAR");
            if ( (Integer)this.mInfo.metaData.get("fullscreen") == 1 ) {
                mView.setSystemUiVisibility(4099);
            }
        } catch (PackageManager.NameNotFoundException e) {
        }
        //////////////////////////////////////////////////

        if (mView != null) {
            mView.onResume();
        }
    }

・ Rebuild

console


rm -rf .buildozer/android/platform/python-for-android/dist
buildozer android debug

Recommended Posts

Kivy-Android Memo (MAC)
kivy-ios memo kivy v1.8.0 (MAC)
Memo on Mac OS X
Python environment construction memo on Mac
Python memo Anaconda installation (Mac only)
Raspberry-pi memo
Pandas memo
HackerRank memo
kivy-ios memo kivy v1.8.0 URL linkage (MAC)
python memo
graphene memo
Flask memo
Matplotlib memo
pytest memo
sed memo
Python memo
Install Memo
networkx memo
python memo
tomcat memo
command memo
Generator memo.
psycopg2 memo
SSH memo
Command memo
Memo: rtl8812
pandas memo
Shell memo
Python memo
Pycharm memo
kivy-ios memo kivy v1.9.0-dev URL linkage (MAC)
Python memo
kivy-ios memo kivy v1.8.0 for new toolchain (MAC)
[For complete beginners] Jupyer Lab shortcut memo [Mac]