LoginSignup
3
3

More than 5 years have passed since last update.

Kivy-Androidメモ(MAC)

Last updated at Posted at 2015-01-09

参考サイト

1.前準備

Kivy-iosメモ(MAC)をBuildできるようにする。
JAVA6 をアップルのサイトからダウンロードしてインストールする。

2.必要モジュールインストール

console
pip install buildozer

3.ビルド

・kivyに付属しているサンプルプログラムのtouchtracerを適当なディレクトリにコピーする。

console
 cd touchtracer
 buildozer init

・buildozer.specというファイルが生成されるので、必要な情報を設定する。Buildozerは、必要なモジュールは自動でダウンロードする。もし、特定のSDKやNDKが必要なら、このファイルにAPIバージョンなどを設定する。

buildozer.spec

# (str) Title of your application
title = Touchtracer  ###アプリケーションのタイトル名

# (str) Package name
package.name = Touchtracer  ###アプリケーションのパッケージ名

# (str) Package domain (needed for android/ios packaging)
package.domain = com.domain  ###アプリケーションのドメイン名
…
…
…
# (list) Source files to include (let empty to include all the files)
source.include_exts = py,png,jpg,kv,atlas  ###必要なファイル名の拡張子を追加
…
…
…
# (str) Application versioning (method 1)
#version.regex = __version__ = ['"](.*)['"]
#version.filename = %(source.dir)s/main.py ###ファイルにバージョンが記述されていない場合はコメント化

# (str) Application versioning (method 2)
version = 0.1.0  ###ファイルにバージョンが記述されていない場合は、コメントを外しバージョンを設定

# (list) Application requirements
# comma seperated e.g. requirements = sqlite3,kivy
requirements = kivy  ###追加で必要なモジュール名を設定  
…
…
…
# (str) Presplash of the application
presplash.filename = %(source.dir)s/png/landscape.png  ###スプラッシュ画面の画像を指定 */

# (str) Icon of the application
icon.filename = %(source.dir)s/png/76pt_x2.png  ###アイコン画像を指定
…
…
…

# (list) Permissions
android.permissions = INTERNET,WRITE_EXTERNAL_STORAGE  ###必要なパーミッションなどを設定
…
…
…
# (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*   ###文字変換用CODECの有効化

・デバックバージョンのパッケージを生成(カレントディレクトリのBIN配下に生成される)

console
 buildozer android debug

・デバックバージョンのパッケージをBUILDLOGを画面表示しながら生成(カレントディレクトリのBIN配下に生成される)

console
buildozer --verbose android debug

・リリースバージョンの生成(カレントディレクトリのBIN配下に生成される)

console
 buildozer android release

4.リリース版への署名

・リリース版は、署名がないとインストールできないので署名する必要がある。正式な証明書があるのならそれを使用する、無い場合は、適当に証明書を生成する(とりあえずインストールして、実行したい場合など)。

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

5.全画面対応

ナビゲートバーを消すには、下記のコードを追加します。ただし、現時点ではスクリーンキーボードが表示されるとナビゲートボタンが表示されてしまいます。

・スペックファイルに修正

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

・Kivy-Androidのソースを修正(onResumeの場所)

.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();
        }
    }

・再ビルド

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

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3