Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App crash with python3 #590

Closed
see01995 opened this issue Nov 29, 2017 · 6 comments
Closed

App crash with python3 #590

see01995 opened this issue Nov 29, 2017 · 6 comments

Comments

@see01995
Copy link

see01995 commented Nov 29, 2017

When I use ndk-r13b to build apk, app can run successfully on android phone.
But when I switch to crystax-ndk-10.3.0/10.3.2,app crashed after presplash on android phone.

buildozer.spec:
buildozer.spec.txt

logcat with android studio:
11-29 15:02:13.620 26328-26328/? W/Zygote: mz_is_rooted true
11-29 15:02:13.624 26328-26328/? I/art: Late-enabling -Xcheck:jni
11-29 15:02:13.651 26328-26328/com.morningsun.choice W/ActivityThread: Application com.morningsun.choice is waiting for the debugger on port 8100...
11-29 15:02:13.652 26328-26328/com.morningsun.choice I/System.out: Sending WAIT chunk
11-29 15:02:25.947 26328-26335/com.morningsun.choice I/art: Debugger is active
11-29 15:02:26.168 26328-26328/com.morningsun.choice I/System.out: Debugger has connected
11-29 15:02:26.168 26328-26328/com.morningsun.choice I/System.out: waiting for debugger to settle...
11-29 15:02:26.368 26328-26328/com.morningsun.choice I/System.out: waiting for debugger to settle...
11-29 15:02:26.568 26328-26328/com.morningsun.choice I/System.out: waiting for debugger to settle...
11-29 15:02:26.768 26328-26328/com.morningsun.choice I/System.out: waiting for debugger to settle...
11-29 15:02:26.969 26328-26328/com.morningsun.choice I/System.out: waiting for debugger to settle...
11-29 15:02:27.169 26328-26328/com.morningsun.choice I/System.out: waiting for debugger to settle...
11-29 15:02:27.369 26328-26328/com.morningsun.choice I/System.out: waiting for debugger to settle...
11-29 15:02:27.570 26328-26328/com.morningsun.choice I/System.out: waiting for debugger to settle...
11-29 15:02:27.770 26328-26328/com.morningsun.choice I/System.out: debugger has settled (1467)
11-29 15:02:30.174 26328-26328/com.morningsun.choice I/PythonActivity: Surface will NOT be transparent
11-29 15:02:30.176 26328-26328/com.morningsun.choice I/Choreographer: Skipped 100 frames!  The application may be doing too much work on its main thread.
11-29 15:02:30.226 26328-26388/com.morningsun.choice I/SDL: SDL_Android_Init()
11-29 15:02:30.226 26328-26388/com.morningsun.choice I/SDL: SDL_Android_Init() finished!
11-29 15:02:30.227 26328-26388/com.morningsun.choice I/python: Initialize Python for Android
11-29 15:02:30.227 26328-26388/com.morningsun.choice I/python: Changing directory to the one provided by ANDROID_ARGUMENT
11-29 15:02:30.227 26328-26388/com.morningsun.choice I/python: /data/user/0/com.morningsun.choice/files/app
11-29 15:02:30.227 26328-26388/com.morningsun.choice I/python: Preparing to initialize python
11-29 15:02:30.227 26328-26388/com.morningsun.choice I/python: crystax_python exists
11-29 15:02:30.227 26328-26388/com.morningsun.choice I/python: calculated paths to be...
11-29 15:02:30.227 26328-26388/com.morningsun.choice I/python: /data/user/0/com.morningsun.choice/files/app/crystax_python/stdlib.zip:/data/user/0/com.morningsun.choice/files/app/crystax_python/modules
11-29 15:02:30.227 26328-26388/com.morningsun.choice I/python: set wchar paths...
11-29 15:02:30.417 26328-26383/com.morningsun.choice I/OpenGLRenderer: Initialized EGL, version 1.4
11-29 15:02:30.422 26328-26383/com.morningsun.choice E/OpenGLRenderer: PerfServiceNative_notifyRenderTime init fail!
11-29 15:02:30.422 26328-26383/com.morningsun.choice I/OpenGLRenderer: Get enable program binary service property (1)
11-29 15:02:30.425 26328-26383/com.morningsun.choice I/OpenGLRenderer: Program binary detail: Binary length is 173456, program map length is 152.
11-29 15:02:30.425 26328-26383/com.morningsun.choice I/OpenGLRenderer: Succeeded to mmap program binaries. File descriptor is 36, and path is /dev/ashmem?.
11-29 15:02:30.425 26328-26383/com.morningsun.choice I/OpenGLRenderer: No need to use file discriptor anymore, close fd(36).
11-29 15:02:30.432 26328-26383/com.morningsun.choice W/libEGL: [ANDROID_RECORDABLE] format: 1
11-29 15:02:30.795 26328-26388/com.morningsun.choice I/python: Initialized python
11-29 15:02:30.795 26328-26388/com.morningsun.choice I/python: AND: Init threads
11-29 15:02:30.795 26328-26388/com.morningsun.choice I/python: testing python print redirection
11-29 15:02:30.797 26328-26388/com.morningsun.choice I/python: Android path ['.', '/data/user/0/com.morningsun.choice/files/app/crystax_python/stdlib.zip', '/data/user/0/com.morningsun.choice/files/app/crystax_python/modules', '/data/user/0/com.morningsun.choice/files/app/crystax_python/site-packages']
11-29 15:02:30.798 26328-26388/com.morningsun.choice I/python: os.environ is environ({'BOOTCLASSPATH': '/system/framework/core-libart.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/telephony-common.jar:/system/framework/voip-common.jar:/system/framework/ims-common.jar:/system/framework/apache-xml.jar:/system/framework/org.apache.http.legacy.boot.jar:/system/framework/mediatek-common.jar:/system/framework/mediatek-framework.jar:/system/framework/mediatek-telephony-common.jar:/system/framework/flyme-framework.jar:/system/framework/flyme-telephony-common.jar:/system/framework/flyme-alipay.jar:/system/framework/com.meizu.camera.jar:/system/framework/meizu2_jcifs.jar:/system/framework/flyme-framework.jar:/system/framework/flyme-telephony-common.jar:/system/framework/com.meizu.camera.jar:/system/framework/flyme-alipay.jar', 'ANDROID_UNPACK': '/data/user/0/com.morningsun.choice/files/app', 'ASEC_MOUNTPOINT': '/mnt/asec', 'LD_PRELOAD': 'libdirect-coredump.so', 'ANDROID_APP_PATH': '/data/user/0/com.morningsun.choice/files/app', 'ANDROID_PROPERTY_WORKSPACE': '9,0', 'PYTHON_NAME': 'python', 'PYTHONOPTIMIZE': '2', 'ANDROID_SOCKET_zygote_secondary': '11', 'PATH': '/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin', 'ANDROID_ENTRYPOINT': 'main.pyo', 'PYTHONPATH': '/data/user/0/com.morningsun.choice/files/app:/data/user/0/com.morningsun.choice/files/app/lib', 'PYTHONHOME': '/data/user/0/com.morningsun.choice/files/app', 'EXTERNAL_STORAGE': '/sdcard', 'ANDROID_ARGUMENT': '/data/user/0/com.morningsun.choice/files/app', 'ANDROID_ROOT': '/system', 'ANDROID_ASSETS': '/system/app', 'ANDROID_DATA': '/data', 'ANDROID_STORAGE': '/storage', 'ANDROID_BOOTLOGO': '1', 'ANDROID_PRIVATE': '/data/user/0/com.morningsun.choice/files', 'SYSTEMSERVERCLASSPATH': '/system/framework/services.jar:/system/framework/ethernet-service.jar:/system/framework/wifi-service.jar'})
11-29 15:02:30.798 26328-26388/com.morningsun.choice I/python: Android kivy bootstrap done. __name__ is __main__
11-29 15:02:30.798 26328-26388/com.morningsun.choice I/python: AND: Ran string
11-29 15:02:30.798 26328-26388/com.morningsun.choice I/python: Run user program, change dir and execute entrypoint
11-29 15:02:30.798 26328-26388/com.morningsun.choice I/python: main.py
11-29 15:02:32.472 26328-26388/com.morningsun.choice I/python: [INFO   ] [Logger      ] Record log in /data/user/0/com.morningsun.choice/files/app/.kivy/logs/kivy_17-11-29_1.txt
11-29 15:02:32.472 26328-26388/com.morningsun.choice I/python: [INFO   ] [Kivy        ] v1.10.0
11-29 15:02:32.473 26328-26388/com.morningsun.choice I/python: [INFO   ] [Python      ] v3.5.0 (default, Dec 11 2015, 11:37:12) 
11-29 15:02:32.473 26328-26388/com.morningsun.choice I/python: [GCC 5.3 20151204]
11-29 15:02:32.481 26328-26388/com.morningsun.choice W/linker: /data/data/com.morningsun.choice/files/app/crystax_python/site-packages/kivy/_clock.so: is missing DT_SONAME will use basename as a replacement: "_clock.so"
11-29 15:02:38.164 26328-26388/com.morningsun.choice W/linker: /data/data/com.morningsun.choice/files/app/crystax_python/site-packages/kivy/_event.so: is missing DT_SONAME will use basename as a replacement: "_event.so"
11-29 15:02:39.516 26328-26388/com.morningsun.choice W/linker: /data/data/com.morningsun.choice/files/app/crystax_python/site-packages/kivy/properties.so: is missing DT_SONAME will use basename as a replacement: "properties.so"
11-29 15:02:40.984 26328-26388/com.morningsun.choice I/python: [INFO   ] [Factory     ] 194 symbols loaded
11-29 15:02:41.690 26328-26388/com.morningsun.choice W/linker: /data/data/com.morningsun.choice/files/app/crystax_python/site-packages/kivy/graphics/instructions.so: is missing DT_SONAME will use basename as a replacement: "instructions.so"
11-29 15:02:42.999 26328-26388/com.morningsun.choice W/linker: /data/data/com.morningsun.choice/files/app/crystax_python/site-packages/kivy/graphics/buffer.so: is missing DT_SONAME will use basename as a replacement: "buffer.so"
11-29 15:02:44.415 26328-26388/com.morningsun.choice W/linker: /data/data/com.morningsun.choice/files/app/crystax_python/site-packages/kivy/graphics/vertex.so: is missing DT_SONAME will use basename as a replacement: "vertex.so"
11-29 15:02:45.859 26328-26388/com.morningsun.choice W/linker: /data/data/com.morningsun.choice/files/app/crystax_python/site-packages/kivy/graphics/cgl.so: is missing DT_SONAME will use basename as a replacement: "cgl.so"
11-29 15:02:47.273 26328-26388/com.morningsun.choice W/linker: /data/data/com.morningsun.choice/files/app/crystax_python/site-packages/kivy/graphics/vbo.so: is missing DT_SONAME will use basename as a replacement: "vbo.so"
11-29 15:02:48.612 26328-26388/com.morningsun.choice W/linker: /data/data/com.morningsun.choice/files/app/crystax_python/site-packages/kivy/graphics/compiler.so: is missing DT_SONAME will use basename as a replacement: "compiler.so"
11-29 15:02:49.998 26328-26388/com.morningsun.choice W/linker: /data/data/com.morningsun.choice/files/app/crystax_python/site-packages/kivy/graphics/transformation.so: is missing DT_SONAME will use basename as a replacement: "transformation.so"
11-29 15:02:51.430 26328-26388/com.morningsun.choice W/linker: /data/data/com.morningsun.choice/files/app/crystax_python/site-packages/kivy/graphics/shader.so: is missing DT_SONAME will use basename as a replacement: "shader.so"
11-29 15:02:52.860 26328-26388/com.morningsun.choice W/linker: /data/data/com.morningsun.choice/files/app/crystax_python/site-packages/kivy/graphics/texture.so: is missing DT_SONAME will use basename as a replacement: "texture.so"
11-29 15:02:54.383 26328-26388/com.morningsun.choice W/linker: /data/data/com.morningsun.choice/files/app/crystax_python/site-packages/kivy/graphics/context_instructions.so: is missing DT_SONAME will use basename as a replacement: "context_instructions.so"
11-29 15:02:56.167 26328-26388/com.morningsun.choice W/linker: /data/data/com.morningsun.choice/files/app/crystax_python/site-packages/kivy/core/image/_img_sdl2.so: is missing DT_SONAME will use basename as a replacement: "_img_sdl2.so"
11-29 15:02:57.516 26328-26388/com.morningsun.choice I/python: [INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2, img_gif (img_pil, img_ffpyplayer ignored)
11-29 15:02:57.526 26328-26388/com.morningsun.choice W/linker: /data/data/com.morningsun.choice/files/app/crystax_python/site-packages/kivy/graphics/fbo.so: is missing DT_SONAME will use basename as a replacement: "fbo.so"
11-29 15:02:58.933 26328-26388/com.morningsun.choice W/linker: /data/data/com.morningsun.choice/files/app/crystax_python/site-packages/kivy/graphics/context.so: is missing DT_SONAME will use basename as a replacement: "context.so"
11-29 15:03:00.462 26328-26388/com.morningsun.choice W/linker: /data/data/com.morningsun.choice/files/app/crystax_python/site-packages/kivy/graphics/opengl.so: is missing DT_SONAME will use basename as a replacement: "opengl.so"
11-29 15:03:01.917 26328-26388/com.morningsun.choice W/linker: /data/data/com.morningsun.choice/files/app/crystax_python/site-packages/kivy/graphics/opengl_utils.so: is missing DT_SONAME will use basename as a replacement: "opengl_utils.so"
11-29 15:03:03.371 26328-26388/com.morningsun.choice W/linker: /data/data/com.morningsun.choice/files/app/crystax_python/site-packages/kivy/graphics/vertex_instructions.so: is missing DT_SONAME will use basename as a replacement: "vertex_instructions.so"
11-29 15:03:04.715 26328-26388/com.morningsun.choice W/linker: /data/data/com.morningsun.choice/files/app/crystax_python/site-packages/kivy/graphics/stencil_instructions.so: is missing DT_SONAME will use basename as a replacement: "stencil_instructions.so"
11-29 15:03:06.262 26328-26388/com.morningsun.choice W/linker: /data/data/com.morningsun.choice/files/app/crystax_python/site-packages/kivy/graphics/gl_instructions.so: is missing DT_SONAME will use basename as a replacement: "gl_instructions.so"
11-29 15:03:07.743 26328-26388/com.morningsun.choice W/linker: /data/data/com.morningsun.choice/files/app/crystax_python/site-packages/kivy/graphics/scissor_instructions.so: is missing DT_SONAME will use basename as a replacement: "scissor_instructions.so"
11-29 15:03:09.147 26328-26388/com.morningsun.choice W/linker: /data/data/com.morningsun.choice/files/app/crystax_python/site-packages/kivy/weakproxy.so: is missing DT_SONAME will use basename as a replacement: "weakproxy.so"
11-29 15:03:10.566 26328-26388/com.morningsun.choice W/linker: /data/data/com.morningsun.choice/files/app/crystax_python/site-packages/kivy/core/text/text_layout.so: is missing DT_SONAME will use basename as a replacement: "text_layout.so"
11-29 15:03:11.989 26328-26388/com.morningsun.choice W/linker: /data/data/com.morningsun.choice/files/app/crystax_python/site-packages/kivy/core/text/_text_sdl2.so: is missing DT_SONAME will use basename as a replacement: "_text_sdl2.so"
11-29 15:03:13.386 26328-26388/com.morningsun.choice I/python: [INFO   ] [Text        ] Provider: sdl2
11-29 15:03:13.835 26328-26388/com.morningsun.choice I/python: [INFO   ] [Font        ]/system/fonts/NotoSansSC-Regular.otf
11-29 15:03:13.835 26328-26388/com.morningsun.choice I/python: [INFO   ] [Font        ]/system/fonts/DroidSans.ttf
11-29 15:03:13.859 26328-26388/com.morningsun.choice W/linker: /data/data/com.morningsun.choice/files/app/crystax_python/site-packages/kivy/core/window/_window_sdl2.so: is missing DT_SONAME will use basename as a replacement: "_window_sdl2.so"
11-29 15:03:18.251 26328-26388/com.morningsun.choice I/python: [INFO   ] [OSC         ] using <multiprocessing> for socket
11-29 15:03:18.263 26328-26388/com.morningsun.choice I/python: [INFO   ] [Window      ] Provider: sdl2
11-29 15:03:18.282 26328-26388/com.morningsun.choice W/linker: /data/data/com.morningsun.choice/files/app/crystax_python/site-packages/kivy/graphics/cgl_backend/cgl_glew.so: is missing DT_SONAME will use basename as a replacement: "cgl_glew.so"
11-29 15:03:19.668 26328-26388/com.morningsun.choice W/linker: /data/data/com.morningsun.choice/files/app/crystax_python/site-packages/kivy/graphics/cgl_backend/cgl_gl.so: is missing DT_SONAME will use basename as a replacement: "cgl_gl.so"
11-29 15:03:21.107 26328-26388/com.morningsun.choice W/libEGL: [ANDROID_RECORDABLE] format: 1
11-29 15:03:21.115 26328-26388/com.morningsun.choice I/python: [INFO   ] [GL          ] Using the "OpenGL ES 2" graphics system
11-29 15:03:21.116 26328-26388/com.morningsun.choice I/python: [INFO   ] [GL          ] Backend used <gl>
11-29 15:03:21.124 26328-26388/com.morningsun.choice I/python: [INFO   ] [GL          ] OpenGL version <b'OpenGL ES 3.1 v1.r7p0-02rel0.a6c0939b3050616905647b55b149c24b'>
11-29 15:03:21.127 26328-26388/com.morningsun.choice I/python: [INFO   ] [GL          ] OpenGL vendor <b'ARM'>
11-29 15:03:21.128 26328-26388/com.morningsun.choice I/python: [INFO   ] [GL          ] OpenGL renderer <b'Mali-T860'>
11-29 15:03:21.128 26328-26388/com.morningsun.choice I/python: [INFO   ] [GL          ] OpenGL parsed version: 3, 1
11-29 15:03:21.129 26328-26388/com.morningsun.choice I/python: [INFO   ] [GL          ] Texture max size <8192>
11-29 15:03:21.129 26328-26388/com.morningsun.choice I/python: [INFO   ] [GL          ] Texture max units <16>
11-29 15:03:21.206 26328-26388/com.morningsun.choice I/python: [INFO   ] [Window      ] auto add sdl2 input provider
11-29 15:03:21.209 26328-26388/com.morningsun.choice I/python: [INFO   ] [Window      ] virtual keyboard not allowed, single mode, not docked
11-29 15:03:21.226 26328-26388/com.morningsun.choice W/linker: /data/data/com.morningsun.choice/files/app/crystax_python/site-packages/jnius/jnius.so: is missing DT_SONAME will use basename as a replacement: "jnius.so"
11-29 15:03:23.316 26328-26388/com.morningsun.choice I/python: [INFO   ] [GL          ] NPOT texture support is available
11-29 15:03:23.319 26328-26388/com.morningsun.choice I/python: [WARNING] [GL          ] Unpack subimage support is not available
11-29 15:03:23.324 26328-26388/com.morningsun.choice I/python: [INFO   ] [App         ]build in
11-29 15:03:23.325 26328-26388/com.morningsun.choice I/python: [INFO   ] [App         ]build out
11-29 15:03:23.326 26328-26388/com.morningsun.choice I/python: [WARNING] [Base        ] Unknown <android> provider
11-29 15:03:23.327 26328-26388/com.morningsun.choice I/python: [INFO   ] [Base        ] Start application main loop
11-29 15:03:23.389 26328-26388/com.morningsun.choice W/linker: /data/data/com.morningsun.choice/files/app/crystax_python/site-packages/android/_android.so: is missing DT_SONAME will use basename as a replacement: "_android.so"
11-29 15:03:24.777 26328-26388/com.morningsun.choice I/python: [INFO   ] [Base        ] Leaving application in progress...
11-29 15:03:25.003 26328-26388/com.morningsun.choice I/python: Python for android ended.

debug

@inclement
Copy link
Member

This logcat doesn't seem to show any error, it's as if the app doesn't actually do anything except import kivy. Can you post the code you used? And is this the whole logcat output, or did you extract only certain lines?

@see01995
Copy link
Author

see01995 commented Nov 30, 2017

The code can run successfully on ubuntu with python2.7 and python3.5.
It also can build with android-ndk-r13b(python2.7) and run successfully on android phone.
Just can't run successfully on android phone by building with crystax-ndk.

Code:

#!/usr/bin/python
# -*- coding: utf-8 -*-

__author__  = ('MorningSun')

try:                                                                                                                                 
    import os,sys,time                                                                                                                  
    import random

    import kivy
    from kivy import resources
    from kivy.logger import Logger
    from kivy.app import App
    from kivy.uix.screenmanager import Screen, ScreenManager 
    from kivy.uix.boxlayout import BoxLayout
    from kivy.uix.label import Label
    from kivy.uix.button import Button
    from kivy.properties import ObjectProperty
    from kivy.clock import Clock
    from kivy.core.text import LabelBase
    from kivy.core.audio import SoundLoader

    if(kivy.platform == 'android'):
        from jnius import autoclass                                                                                                      
        from jnius import cast
        from plyer import accelerometer,vibrator                                                                                                         
except ImportError as err:                                                                                                             
    print("couldn't load module. %s" % (err))
    sys.exit()                                                                                                                       

#LabelBase.register('DroidSansFallback',os.path.join(os.getcwd(),'DroidSansFallback.ttf'))
if(kivy.platform == 'android'):
    resources.resource_add_path('/system/fonts')
    Logger.info("Font:%s" % resources.resource_find("NotoSansSC-Regular.otf"))
    Logger.info("Font:%s" % resources.resource_find("DroidSans.ttf"))
    #LabelBase.register('NotoSansSC',resources.resource_find("NotoSansSC-Regular.otf"))
    LabelBase.register('NotoSansSC',resources.resource_find("DroidSans.ttf"))

SPEED_SHRESHOLD = 1000
UPTATE_INTERVAL_TIME = 0.2

class Choice(App):


    def build(self):
        Logger.info("App:build in")
        Logger.info("App:build out")
        self.sound = SoundLoader.load('shake.ogg')
        self.files = {}
        self.rand_flag = False
        self.shake_flag = False
        self.x_his=0
        self.y_his=0
        self.z_his=0
        self.x=0
        self.y=0
        self.z=0
        if(kivy.platform == 'android'):
            accelerometer.enable()
            #Hardware = autoclass('org.renpy.android.Hardware')
            #print('DPI is', Hardware.getDPI())

            #Hardware.accelerometerEnable(True)
            #for x in xrange(20):
            #    print(Hardware.accelerometerReading())
            #    time.sleep(.1)

            Clock.schedule_interval(self.get_acc,UPTATE_INTERVAL_TIME)
        Clock.schedule_interval(self.random_run,UPTATE_INTERVAL_TIME)
        
    def get_acc(self,dt):
        #pass
        if(kivy.platform == 'android'):
            val = accelerometer.acceleration[:3]
            if(val != (None,None,None)):
                #print('x=%s' % str(val[0]))
                #print('y=%s' % str(val[1]))
                #print('z=%s' % str(val[2]))
                self.x_his = self.x
                self.y_his = self.y
                self.z_his = self.z
                self.x = val[0]
                self.y = val[1]
                self.z = val[2]
                if(self.x_his,self.y_his,self.z_his) != (0,0,0):
                    delta_x = self.x - self.x_his
                    delta_y = self.y - self.y_his
                    delta_z = self.z - self.z_his
                    #print(UPTATE_INTERVAL_TIME)
                    speed = ((delta_x**2 + delta_y**2 + delta_z**2)**0.5) * 1000
                    if(speed > 10000):
                        self.sound.play()
                        Clock.schedule_once(self.on_shake,0)
                        print('speed:%d' % speed)


    def on_shake(self,dt):
        print('detect shake')
        if(self.rand_flag==False):
            self.rand_flag = True
            #self.rand_flag= not self.rand_flag
            print('pre shake')
            self.random_run()
            #vibrator.vibrate(0.1)
            #time.sleep(0.5)
            self.rand_flag = False
            print('post shake')
  
#speed = Math.sqrt(deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ)/ timeInterval * 10000

    def on_select(self):
        self.files = {}
        self.root.ids.kind.text = '';
        self.root.ids.select_dirs.text  = ''
        for dir_path in self.root.ids.filechooser.selection:
            filelist = os.listdir(dir_path)
            kind = os.path.split(dir_path)[1]
            for item in filelist:
                self.files[os.path.splitext(item)[0]] = os.path.join(dir_path,item)
            self.root.ids.select_dirs.text += dir_path+'\n';
            self.root.ids.kind.text += kind+' ';
        print(self.files.keys())
        print(self.files.items())
        if(len(self.files)==0):
            self.root.ids.item.text         = 'Empty directory'
            self.root.ids.select_dirs.text  = 'Empty directory,Please select again!'
        else:
            self.root.ids.item.text     = 'Touch to Start'
        self.root.ids.image.source  = os.path.join(os.getcwd(),'icon.png')

    def on_confirm(self):
        if(len(self.files)!=0):
            self.root.current = 'main'


    def random_start(self):
        if(len(self.root.ids.filechooser.selection) != 0):
            if(self.rand_flag == False):
                self.rand_flag = True
                #print("random start")
                #self.random_run()
    
    def random_run(self,dt=0):
        if(self.rand_flag == True):
            if(len(self.files)!=0):
                self.root.ids.item.text     = list(self.files.keys())[random.randint(0,len(self.files)-1)]
                self.root.ids.image.source  = self.files[self.root.ids.item.text]


    def random_stop(self):
        self.rand_flag = False
        #print("random stop")


# Call for main definition upon initialization.
if __name__ == '__main__':
    fp = open('log.txt','w')
    sys.stdout = fp
    sys.stderr = fp
    print('system:%s' % kivy.platform)
    Choice().run()
    fp.close()

@see01995
Copy link
Author

i debuged apk with android studio.
the log copied from android studio's logcat windows.

@inclement
Copy link
Member

inclement commented Nov 30, 2017

Did you check the log.txt that you're writing to? It's likely that your overriding of sys.stdout and sys.stderr are obscuring error messages that would normally be output via logcat.

@see01995
Copy link
Author

see01995 commented Dec 5, 2017

I found the error reported in log.txt, it is an issue of string.
Thank you for your help

@see01995
Copy link
Author

see01995 commented Dec 5, 2017

The log.txt reported the error:
Traceback (most recent call last):
File "main.py", line 161, in
Choice().run()
File "/data/user/0/com.morningsun.choice/files/app/crystax_python/site-packages/kivy/app.py", line 828, in run
runTouchApp()
File "/data/user/0/com.morningsun.choice/files/app/crystax_python/site-packages/kivy/base.py", line 504, in runTouchAp
p
EventLoop.window.mainloop()
File "/data/user/0/com.morningsun.choice/files/app/crystax_python/site-packages/kivy/core/window/window_sdl2.py", line
663, in mainloop
self._mainloop()
File "/data/user/0/com.morningsun.choice/files/app/crystax_python/site-packages/kivy/core/window/window_sdl2.py", line
405, in _mainloop
EventLoop.idle()
File "/data/user/0/com.morningsun.choice/files/app/crystax_python/site-packages/kivy/base.py", line 339, in idle
Clock.tick()
File "/data/user/0/com.morningsun.choice/files/app/crystax_python/site-packages/kivy/clock.py", line 581, in tick
self._process_events()
File "kivy/_clock.pyx", line 367, in kivy._clock.CyClockBase._process_events (kivy/_clock.c:7700)
File "kivy/_clock.pyx", line 397, in kivy._clock.CyClockBase._process_events (kivy/_clock.c:7577)
File "kivy/_clock.pyx", line 395, in kivy._clock.CyClockBase._process_events (kivy/_clock.c:7498)
File "kivy/_clock.pyx", line 167, in kivy._clock.ClockEvent.tick (kivy/_clock.c:3490)
File "/data/user/0/com.morningsun.choice/files/app/crystax_python/site-packages/kivy/base.py", line 210, in remove_and
roid_splash
from android import remove_presplash
File "/data/user/0/com.morningsun.choice/files/app/crystax_python/site-packages/android/init.py", line 8, in
from android._android import *
File "android/_android.pyx", line 178, in init android._android (android/_android.c:6886)
TypeError: can't concat bytes to str

I has searched the same issue in kivy/python-for-android #1093, is it resolve?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants