Kivy Launcherというpythonで書かれたアプリあり、それとPythonインタープリターを含んだAndroidのAPKを作ってAndroid端末上で動作させているのですが、原因の分からないerrorに困っています。Kivy Launcherは別のpythonプログラムを立ち上げるアプリ(名前の通りKivyを使ったPythonプログラムを立ち上げます)で、その際に内部でpyjniusというJavaのclassをPython側から操作する為のmodule
を使ってAndroidのAPIを叩いています。
Kivy Launcherにはstart_android_activity()という関数があるのですが、この関数を以下のように書き換えた所
python
1 def start_android_activity(self, entry): 2 from kivy.logger import Logger # 変更点 A 3 from jnius import autoclass 4 5 PythonActivity = autoclass("org.kivy.android.PythonActivity") 6 System = autoclass("java.lang.System") 7 activity = PythonActivity.mActivity 8 Intent = autoclass("android.content.Intent") 9 String = autoclass("java.lang.String") 10 11 j_entrypoint = String(entry.get("entrypoint")) 12 j_orientation = String(entry.get("orientation")) 13 intent = Intent( 14 activity.getApplicationContext(), 15 PythonActivity) 16 intent.putExtra("entrypoint", j_entrypoint) 17 intent.putExtra("orientation", j_orientation) 18 activity.startActivity(intent) 19 Logger.info("APP: This line will be printed") # 変更点 B このlogは出力される 20 System.exit(0) 21 Logger.info("APP: This line won't be printed") # 変更点 C このlogは出力されない
次のlogが得られました。
I/python (11086): [INFO ] [APP ] This line will be printed W/InputDispatcher( 556): channel '10f1953e jp.gottadiveintopython.launcher/org.kivy.android.PythonActivity (server)' ~ Consumer closed input channel or an error occurred. events=0x9 E/InputDispatcher( 556): channel '10f1953e jp.gottadiveintopython.launcher/org.kivy.android.PythonActivity (server)' ~ Channel is unrecoverably broken and will be disposed! W/InputDispatcher( 556): Attempted to unregister already unregistered input channel '10f1953e jp.gottadiveintopython.launcher/org.kivy.android.PythonActivity (server)' W/ActivityManager( 556): Force removing ActivityRecord{e013924 u0 jp.gottadiveintopython.launcher/org.kivy.android.PythonActivity t947}: app died, no saved state
C行は出力されず(System.exit(0)
がprocessの終了を意味しているのなら納得)、activity.startActivity(intent)
で立ち上げたactivityが表示されません。また出てきたerrorをググってもこれといった解決策はみつけられませんでした。どなたか教えてくれると助かります。
他の情報
- Android端末のOSのversionは 5.0.1
- apkに組み込んだpythonのversionは3.7.1
- 一日前にKivy Launcherを正常に動かす事に成功している
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。