在Android手机上用kivy崩溃写的android应用程序

时间:2017-09-19 09:35:39

标签: android python python-2.7 kivy buildozer

我尝试使用kivy,buildozer

在python中制作简单的Android应用程序

代码

from kivy.app import App

from kivy.uix.scatter import Scatter
from kivy.uix.label import Label
from kivy.uix.floatlayout import FloatLayout

class TutorialApp(App):
    def build(self):
        f = FloatLayout()
        s = Scatter()
        l = Label(text="Hello!",
                  font_size=150)

        f.add_widget(s)
        s.add_widget(l)
        return f

if __name__ == "__main__":
    TutorialApp().run()

CODE SOURCE

我使用buildozer -v android debug命令制作apk,然后使用adb install <app name>命令安装在Android设备上

adb logcat输出

E/SoundPool(  375): error loading /system/media/audio/ui/Effect_Tick.ogg
W/AudioService(  375): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
E/SoundPool(  375): error loading /system/media/audio/ui/Effect_Tick.ogg
W/AudioService(  375): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
E/SoundPool(  375): error loading /system/media/audio/ui/Effect_Tick.ogg
W/AudioService(  375): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
E/SoundPool(  375): error loading /system/media/audio/ui/Effect_Tick.ogg
W/AudioService(  375): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
E/SoundPool(  375): error loading /system/media/audio/ui/Effect_Tick.ogg
W/AudioService(  375): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
E/SoundPool(  375): error loading /system/media/audio/ui/KeypressStandard.ogg
W/AudioService(  375): Soundpool could not load file: /system/media/audio/ui/KeypressStandard.ogg
E/SoundPool(  375): error loading /system/media/audio/ui/KeypressSpacebar.ogg
W/AudioService(  375): Soundpool could not load file: /system/media/audio/ui/KeypressSpacebar.ogg
E/SoundPool(  375): error loading /system/media/audio/ui/KeypressDelete.ogg
W/AudioService(  375): Soundpool could not load file: /system/media/audio/ui/KeypressDelete.ogg
E/SoundPool(  375): error loading /system/media/audio/ui/KeypressReturn.ogg
W/AudioService(  375): Soundpool could not load file: /system/media/audio/ui/KeypressReturn.ogg
E/SoundPool(  375): error loading /system/media/audio/ui/KeypressInvalid.ogg
W/AudioService(  375): Soundpool could not load file: /system/media/audio/ui/KeypressInvalid.ogg
W/AudioService(  375): onLoadSoundEffects(), Error -1 while loading samples
I/ActivityManager(  375): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=org.test.kivycrash2/org.kivy.android.PythonActivity} from pid 532
D/gralloc (   55): Registering a buffer in the process that created it. This may cause memory ordering problems.
E/libEGL  (   55): called unimplemented OpenGL ES API
E/libEGL  (   55): called unimplemented OpenGL ES API
E/libEGL  (   55): called unimplemented OpenGL ES API
E/libEGL  (   55): called unimplemented OpenGL ES API
E/SurfaceFlinger(   55): glCheckFramebufferStatusOES error -1903290099
E/SurfaceFlinger(   55): got GL_FRAMEBUFFER_COMPLETE_OES error while taking screenshot
E/libEGL  (   55): called unimplemented OpenGL ES API
E/libEGL  (   55): called unimplemented OpenGL ES API
W/WindowManager(  375): Screenshot failure taking screenshot for (328x524) to layer 21010
D/dalvikvm( 1793): Not late-enabling CheckJNI (already on)
I/ActivityManager(  375): Start proc org.test.kivycrash2 for activity org.test.kivycrash2/org.kivy.android.PythonActivity: pid=1793 uid=10061 gids={50061, 1028, 1015}
V/PythonActivity( 1793): My oncreate running
V/PythonActivity( 1793): About to do super onCreate
V/SDL     ( 1793): Device: generic
V/SDL     ( 1793): Model: google_sdk
V/SDL     ( 1793): onCreate():null
V/PythonActivity( 1793): Did super onCreate
V/SDL     ( 1793): getting identifier
V/SDL     ( 1793): kind is drawable and name presplash
V/SDL     ( 1793): result is 2130837506
D/dalvikvm( 1793): GC_FOR_ALLOC freed 27K, 4% free 2899K/2992K, paused 119ms, total 120ms
I/dalvikvm-heap( 1793): Grow heap (frag case) to 3.392MB for 524304-byte allocation
D/dalvikvm( 1793): GC_FOR_ALLOC freed <1K, 3% free 3411K/3508K, paused 69ms, total 69ms
D/dalvikvm( 1793): GC_CONCURRENT freed <1K, 3% free 3411K/3508K, paused 3ms+1ms, total 48ms
I/Choreographer(  532): Skipped 60 frames!  The application may be doing too much work on its main thread.
V/SDL     ( 1793): asked to get string presplash_color
V/SDL     ( 1793): getting identifier
V/SDL     ( 1793): kind is string and name presplash_color
V/SDL     ( 1793): result is 2130968578
V/PythonActivity( 1793): onResume()
V/SDL     ( 1793): onResume()
V/SDL     ( 1793): onWindowFocusChanged(): true
D/gralloc_goldfish( 1793): Emulator without host-side GPU emulation detected. Loading gralloc.default.so from /vendor/lib/hw/gralloc.default.so...
D/gralloc_goldfish( 1793): gralloc.default.so not found in /vendor. Trying /system/lib/hw/gralloc.default.so...
I/ActivityManager(  375): Displayed org.test.kivycrash2/org.kivy.android.PythonActivity: +1s85ms
V/PythonActivity( 1793): Ready to unpack
V/PythonActivity( 1793): UNPACKING!!! private app
V/SDL     ( 1793): asked to get string private_version
V/SDL     ( 1793): getting identifier
V/SDL     ( 1793): kind is string and name private_version
V/SDL     ( 1793): result is 2130968577
V/PythonActivity( 1793): Data version is 1505813185.71
V/pythonutil( 1793): Loading library: SDL2
D/dalvikvm( 1793): Trying to load lib /data/app-lib/org.test.kivycrash2-1/libSDL2.so 0xb1d3b060
D/dalvikvm( 1793): Added shared lib /data/app-lib/org.test.kivycrash2-1/libSDL2.so 0xb1d3b060
V/pythonutil( 1793): Loading library: SDL2_image
D/dalvikvm( 1793): Trying to load lib /data/app-lib/org.test.kivycrash2-1/libSDL2_image.so 0xb1d3b060
D/dalvikvm( 1793): Added shared lib /data/app-lib/org.test.kivycrash2-1/libSDL2_image.so 0xb1d3b060
D/dalvikvm( 1793): No JNI_OnLoad found in /data/app-lib/org.test.kivycrash2-1/libSDL2_image.so 0xb1d3b060, skipping init
V/pythonutil( 1793): Loading library: SDL2_mixer
D/dalvikvm( 1793): Trying to load lib /data/app-lib/org.test.kivycrash2-1/libSDL2_mixer.so 0xb1d3b060
D/dalvikvm( 1793): Added shared lib /data/app-lib/org.test.kivycrash2-1/libSDL2_mixer.so 0xb1d3b060
D/dalvikvm( 1793): No JNI_OnLoad found in /data/app-lib/org.test.kivycrash2-1/libSDL2_mixer.so 0xb1d3b060, skipping init
V/pythonutil( 1793): Loading library: SDL2_ttf
D/dalvikvm( 1793): Trying to load lib /data/app-lib/org.test.kivycrash2-1/libSDL2_ttf.so 0xb1d3b060
D/dalvikvm( 1793): Added shared lib /data/app-lib/org.test.kivycrash2-1/libSDL2_ttf.so 0xb1d3b060
D/dalvikvm( 1793): No JNI_OnLoad found in /data/app-lib/org.test.kivycrash2-1/libSDL2_ttf.so 0xb1d3b060, skipping init
V/pythonutil( 1793): Loading library: python2.7
D/dalvikvm( 1793): Trying to load lib /data/app-lib/org.test.kivycrash2-1/libpython2.7.so 0xb1d3b060
D/dalvikvm( 1793): Added shared lib /data/app-lib/org.test.kivycrash2-1/libpython2.7.so 0xb1d3b060
D/dalvikvm( 1793): No JNI_OnLoad found in /data/app-lib/org.test.kivycrash2-1/libpython2.7.so 0xb1d3b060, skipping init
V/pythonutil( 1793): Loading library: python3.5m
V/pythonutil( 1793): Library loading error: Couldn't load python3.5m from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/org.test.kivycrash2-1.apk"],nativeLibraryDirectories=[/data/app-lib/org.test.kivycrash2-1, /vendor/lib, /system/lib]]]: findLibrary returned null
V/pythonutil( 1793): Loading library: python3.6m
V/pythonutil( 1793): Library loading error: Couldn't load python3.6m from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/org.test.kivycrash2-1.apk"],nativeLibraryDirectories=[/data/app-lib/org.test.kivycrash2-1, /vendor/lib, /system/lib]]]: findLibrary returned null
V/pythonutil( 1793): Loading library: main
D/dalvikvm( 1793): Trying to load lib /data/app-lib/org.test.kivycrash2-1/libmain.so 0xb1d3b060
D/dalvikvm( 1793): Added shared lib /data/app-lib/org.test.kivycrash2-1/libmain.so 0xb1d3b060
D/dalvikvm( 1793): No JNI_OnLoad found in /data/app-lib/org.test.kivycrash2-1/libmain.so 0xb1d3b060, skipping init
D/dalvikvm( 1793): Trying to load lib /data/data/org.test.kivycrash2/files/app/lib/python2.7/lib-dynload/_io.so 0xb1d3b060
D/dalvikvm( 1793): Added shared lib /data/data/org.test.kivycrash2/files/app/lib/python2.7/lib-dynload/_io.so 0xb1d3b060
D/dalvikvm( 1793): No JNI_OnLoad found in /data/data/org.test.kivycrash2/files/app/lib/python2.7/lib-dynload/_io.so 0xb1d3b060, skipping init
D/dalvikvm( 1793): Trying to load lib /data/data/org.test.kivycrash2/files/app/lib/python2.7/lib-dynload/unicodedata.so 0xb1d3b060
D/dalvikvm( 1793): Added shared lib /data/data/org.test.kivycrash2/files/app/lib/python2.7/lib-dynload/unicodedata.so 0xb1d3b060
D/dalvikvm( 1793): No JNI_OnLoad found in /data/data/org.test.kivycrash2/files/app/lib/python2.7/lib-dynload/unicodedata.so 0xb1d3b060, skipping init
D/dalvikvm( 1793): Trying to load lib /data/data/org.test.kivycrash2/files/app/lib/python2.7/lib-dynload/_ctypes.so 0xb1d3b060
D/dalvikvm( 1793): Added shared lib /data/data/org.test.kivycrash2/files/app/lib/python2.7/lib-dynload/_ctypes.so 0xb1d3b060
D/dalvikvm( 1793): No JNI_OnLoad found in /data/data/org.test.kivycrash2/files/app/lib/python2.7/lib-dynload/_ctypes.so 0xb1d3b060, skipping init
V/pythonutil( 1793): Loaded everything!
V/PythonActivity( 1793): Setting env vars for start.c and Python to use
V/PythonActivity( 1793): Access to our meta-data...
I/PythonActivity( 1793): Surface will NOT be transparent
V/SDL     ( 1793): surfaceCreated()
V/SDL     ( 1793): surfaceChanged()
V/SDL     ( 1793): pixel format RGB_565
V/SDL     ( 1793): Window size:800x1134
I/SDL     ( 1793): SDL_Android_Init()
I/SDL     ( 1793): SDL_Android_Init() finished!
I/python  ( 1793): Initialize Python for Android
I/python  ( 1793): Changing directory to the one provided by ANDROID_ARGUMENT
I/python  ( 1793): /data/data/org.test.kivycrash2/files/app
I/python  ( 1793): Preparing to initialize python
I/python  ( 1793): crystax_python does not exist
I/python  ( 1793): Initialized python
I/python  ( 1793): AND: Init threads
I/python  ( 1793): testing python print redirection
I/python  ( 1793): Setting up python from ANDROID_PRIVATE
I/python  ( 1793): ('Android path', ['/data/data/org.test.kivycrash2/files/app/lib/python27.zip', '/data/data/org.test.kivycrash2/files/app/lib/python2.7/', '/data/data/org.test.kivycrash2/files/app/lib/python2.7/lib-dynload/', '/data/data/org.test.kivycrash2/files/app/lib/python2.7/site-packages/', '/data/data/org.test.kivycrash2/files/app'])
I/python  ( 1793): ('os.environ is', {'ANDROID_APP_PATH': '/data/data/org.test.kivycrash2/files/app', 'EXTERNAL_STORAGE': '/storage/sdcard', 'LOOP_MOUNTPOINT': '/mnt/obb', 'ANDROID_SOCKET_zygote': '9', 'BOOTCLASSPATH': '/system/framework/core.jar:/system/framework/conscrypt.jar:/system/framework/okhttp.jar:/system/framework/core-junit.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/framework2.jar:/system/framework/telephony-common.jar:/system/framework/voip-common.jar:/system/framework/mms-common.jar:/system/framework/android.policy.jar:/system/framework/services.jar:/system/framework/apache-xml.jar:/system/framework/webviewchromium.jar', 'ANDROID_PROPERTY_WORKSPACE': '8,0', 'PATH': '/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin', 'ANDROID_STORAGE': '/storage', 'ANDROID_BOOTLOGO': '1', 'ANDROID_DATA': '/data', 'ANDROID_ASSETS': '/system/app', 'LD_LIBRARY_PATH': '/vendor/lib:/system/lib', 'PYTHONOPTIMIZE': '2', 'ANDROID_PRIVATE': '/data/data/org.test.kivycrash2/files', 'ANDROID_ENTRYPOINT': 'main.pyo', 'PYTHONPATH': '/data/data/org.test.kivycrash2/files/app:/data/data/org.test.kivycrash2/files/app/lib', 'ANDROID_UNPACK': '/data/data/org.test.kivycrash2/files/app', 'PYTHON_NAME': 'python', 'ANDROID_ROOT': '/system', 'PYTHONHOME': '/data/data/org.test.kivycrash2/files/app', 'ASEC_MOUNTPOINT': '/mnt/asec', 'ANDROID_ARGUMENT': '/data/data/org.test.kivycrash2/files/app'})
I/python  ( 1793): ('Android kivy bootstrap done. __name__ is', '__main__')
I/python  ( 1793): ['/data/data/org.test.kivycrash2/files/app/lib/python2.7/site-packages', '/data/data/org.test.kivycrash2/files/app/lib/site-python']
I/python  ( 1793): AND: Ran string
I/python  ( 1793): Run user program, change dir and execute entrypoint
I/python  ( 1793): Purge log fired. Analysing...
I/python  ( 1793): Purge finished!
I/python  ( 1793): [INFO   ] [Logger      ] Record log in /data/data/org.test.kivycrash2/files/app/.kivy/logs/kivy_17-09-19_1.txt
I/python  ( 1793): [INFO   ] [Kivy        ] v1.10.0
I/python  ( 1793): [INFO   ] [Python      ] v2.7.2 (default, Sep 12 2017, 15:06:04) 
I/python  ( 1793): [GCC 4.8]
I/python  ( 1793): [INFO   ] [Factory     ] 194 symbols loaded
I/python  ( 1793): [INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2, img_gif (img_pil, img_ffpyplayer ignored)
I/python  ( 1793): [INFO   ] [Text        ] Provider: sdl2
I/python  ( 1793): [INFO   ] [OSC         ] using <thread> for socket
I/python  ( 1793): [INFO   ] [Window      ] Provider: sdl2
I/python  ( 1793): [CRITICAL] [Window      ] Unable to find any valuable Window provider.
I/python  ( 1793): sdl2 - RuntimeError: Could not create GLES window surface
I/python  ( 1793):   File "/home/kallz/Document/.buildozer/android/platform/build/dists/kivycrash2/private/lib/python2.7/site-packages/kivy/core/__init__.py", line 67, in core_select_lib
I/python  ( 1793):   File "/home/kallz/Document/.buildozer/android/platform/build/dists/kivycrash2/private/lib/python2.7/site-packages/kivy/core/window/window_sdl2.py", line 140, in __init__
I/python  ( 1793):   File "/home/kallz/Document/.buildozer/android/platform/build/dists/kivycrash2/private/lib/python2.7/site-packages/kivy/core/window/__init__.py", line 899, in __init__
I/python  ( 1793):   File "/home/kallz/Document/.buildozer/android/platform/build/dists/kivycrash2/private/lib/python2.7/site-packages/kivy/core/window/window_sdl2.py", line 269, in create_window
I/python  ( 1793):   File "kivy/core/window/_window_sdl2.pyx", line 142, in kivy.core.window._window_sdl2._WindowSDL2Storage.setup_window (kivy/core/window/_window_sdl2.c:2263)
I/python  ( 1793):   File "kivy/core/window/_window_sdl2.pyx", line 57, in kivy.core.window._window_sdl2._WindowSDL2Storage.die (kivy/core/window/_window_sdl2.c:1461)
I/python  ( 1793): [CRITICAL] [App         ] Unable to get a Window, abort.
I/ActivityManager(  375): Process org.test.kivycrash2 (pid 1793) has died.
I/WindowState(  375): WIN DEATH: Window{b21de1e8 u0 org.test.kivycrash2/org.kivy.android.PythonActivity}
W/WindowManager(  375): Force-removing child win Window{b2155690 u0 SurfaceView} from container Window{b21de1e8 u0 org.test.kivycrash2/org.kivy.android.PythonActivity}
W/ActivityManager(  375): Force removing ActivityRecord{b21ebc18 u0 org.test.kivycrash2/org.kivy.android.PythonActivity t9}: app died, no saved state
D/Zygote  (   56): Process 1793 exited cleanly (1)
W/WindowManager(  375): Failed looking up window
W/WindowManager(  375): java.lang.IllegalArgumentException: Requested window android.os.BinderProxy@b212b238 does not exist
W/WindowManager(  375):         at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:7923)
W/WindowManager(  375):         at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:7914)
W/WindowManager(  375):         at com.android.server.wm.WindowState$DeathRecipient.binderDied(WindowState.java:1047)
W/WindowManager(  375):         at android.os.BinderProxy.sendDeathNotice(Binder.java:493)
W/WindowManager(  375):         at dalvik.system.NativeStart.run(Native Method)
I/WindowState(  375): WIN DEATH: null
W/InputMethodManagerService(  375): Got RemoteException sending setActive(false) notification to pid 1793 uid 10061
W/Binder  (  492): Caught a RuntimeException from the binder stub implementation.
W/Binder  (  492): java.lang.NullPointerException
W/Binder  (  492):      at android.inputmethodservice.IInputMethodWrapper.setSessionEnabled(IInputMethodWrapper.java:280)
W/Binder  (  492):      at com.android.internal.view.IInputMethod$Stub.onTransact(IInputMethod.java:129)
W/Binder  (  492):      at android.os.Binder.execTransact(Binder.java:404)
W/Binder  (  492):      at dalvik.system.NativeStart.run(Native Method)

我不知道为什么会出现此错误以及如何解决此问题。

从上面的日志错误点是

 [INFO   ] [Window      ] Provider: sdl2
I/python  ( 1793): [CRITICAL] [Window      ] Unable to find any valuable Window provider.
I/python  ( 1793): sdl2 - RuntimeError: Could not create GLES window surface
I/python  ( 1793):   File "/home/kallz/Document/.buildozer/android/platform/build/dists/kivycrash2/private/lib/python2.7/site-packages/kivy/core/__init__.py", line 67, in core_select_lib
I/python  ( 1793):   File "/home/kallz/Document/.buildozer/android/platform/build/dists/kivycrash2/private/lib/python2.7/site-packages/kivy/core/window/window_sdl2.py", line 140, in __init__
I/python  ( 1793):   File "/home/kallz/Document/.buildozer/android/platform/build/dists/kivycrash2/private/lib/python2.7/site-packages/kivy/core/window/__init__.py", line 899, in __init__
I/python  ( 1793):   File "/home/kallz/Document/.buildozer/android/platform/build/dists/kivycrash2/private/lib/python2.7/site-packages/kivy/core/window/window_sdl2.py", line 269, in create_window
I/python  ( 1793):   File "kivy/core/window/_window_sdl2.pyx", line 142, in kivy.core.window._window_sdl2._WindowSDL2Storage.setup_window (kivy/core/window/_window_sdl2.c:2263)
I/python  ( 1793):   File "kivy/core/window/_window_sdl2.pyx", line 57, in kivy.core.window._window_sdl2._WindowSDL2Storage.die (kivy/core/window/_window_sdl2.c:1461)
I/python  ( 1793): [CRITICAL] [App         ] Unable to get a Window, abort.
I/ActivityManager(  375): Process org.test.kivycrash2 (pid 1793) has died

1 个答案:

答案 0 :(得分:0)

在AVD管理器中编辑Android设备并在模拟选项下确保选中使用主机GPU。