Kivy Gallary programm doesn't work when compiled as apk
<p>I wanted to make an kivy app, with a button, that opens the android gallary, when the button is clicked.
So I wrote to code, that you can see down there, on qpython, and it worked.
But when I wanted to ran it on my PC, I got the error message:</p>

<pre><code>     Traceback (most recent call last):
   File "main.py", line 35, in &lt;module&gt;
     from gallery import Gallary
   File "/home/gilgamesch/Apps/event/gallery.py", line 14, in &lt;module&gt;
     from android import activity
 ImportError: No module named android
</code></pre>

<p>(Yes, this is the whole error message)</p>

<p>But I decided to give it a try anyway.
So I compiled it with buildozer, installed and started it on my android phone, and the application started.
It opened, I clicked on he button, and the gallary opened too, but as soon, as I choose an image, the programm crashed.</p>

<p>Here is the main.py:</p>

<pre><code>#-*-coding:utf8;-*-
#qpy:2
#qpy:kivy

from kivy.app import App
from kivy.uix.button import Button
from kivy.properties import StringProperty

from gallery import Gallary


class TestApp(App):
    path = StringProperty()
    def build(self):


        return Button(text='Hello QPython', on_release=self.open_g)
    def open_g(self, *args):
        self.g = Gallary()

        path = self.g.make_gallary(self.getstr)

    def getstr(self, path):
        self.path = path
        print self.path + 'in Gallary class'

    def on_pause(self):
        return True

    def on_resume(self):
        pass


TestApp().run()
</code></pre>

<p>And here is my self made Gallary module:</p>

<pre><code>#-*-coding:utf8;-*-
#qpy:2
#qpy:kivy

from jnius import autoclass
from jnius import cast

from android import activity


class Gallary(object):
    def __init__(self, *args):

        self.mypath = ''

        # import the needed Java class 
        self.PythonActivity = autoclass ('org.renpy.android.PythonActivity')
        self.Activity = autoclass('android.app.Activity')

        self.uri = autoclass('android.net.Uri')
        self.intent = autoclass('android.content.Intent')
        self.MediaStore = autoclass('android.provider.MediaStore')
        self.Cursor = autoclass('android.database.Cursor')


        # Value of MediaStore.Images.Media.DATA
        self.MediaStore_Images_Media_DATA = "_data"



        self.gallerie = self.intent()
        self.gallerie.setType("image/*")
        self.gallerie.setAction(self.intent.ACTION_GET_CONTENT)



    def getPath(self, Iuri, *args):
        if Iuri == None:
            return ''
        self.projektion = [self.MediaStore_Images_Media_DATA]

        self.cursor = self.currentActivity.getContentResolver().query(Iuri, self.projektion, None, None, None)
        if self.cursor != None:
            cindex = self.cursor.getColumnIndexOrThrow(self.MediaStore_Images_Media_DATA)
            self.cursor.moveToFirst()
            return self.cursor.getString(cindex)
        return Iuri.getPath()

    def on_activity_result(self, requestCode, resultCode, data):

        print "### ACTIVITY CALLBACK ###"
        if resultCode == self.PythonActivity.RESULT_OK:
            if requestCode == 1:

                myuri = data.getData()
                self.mypath = self.getPath(myuri)
                self.give(self.mypath)
                #print self.mypath

    def make_gallary(self, give):

        self.currentActivity = cast('android.app.Activity', self.PythonActivity.mActivity)
        self.currentActivity.startActivityForResult(self.intent.createChooser(self.gallerie, "Choose Image"), 1)
        #print 'made gallery'
        self.give = give

        activity.bind(on_activity_result=self.on_activity_result)

        return self.mypath

    def get_str(self):
        return self.mypath
    def give(self):
     pass
</code></pre>

<p>And Here are the permissions, I gave the App in the buildozer.spec file:</p>

<pre><code># (list) Permissions
android.permissions = INTERNET,ACCESS_WIFI_STATE,READ_PHONE_STATE,ACCESS_NETWORK_STATE,READ_EXTERNAL_STORAGE,WRITE_EXTERNAL_STORAGE
</code></pre>

<p>And Here is the part of the logicat, that says something with gallary:</p>

<pre><code>D/GalleryActivityLifecycleCallback(15128): destroyed : count 1
D/ThumbnailProxy(15128): stop()
D/ThumbnailProxy(15128): stop()
D/ThumbnailProxy(15128): stop()
D/KeyguardUpdateMonitor( 1015): sendKeyguardVisibilityChanged(true)
D/KeyguardUpdateMonitor( 1015): handleKeyguardVisibilityChanged(1)
D/CustomFrequencyManagerService(  785): acquireDVFSLockLocked : type : DVFS_MIN_LIMIT  frequency : 1190400  uid : 1000  pid : 785  pkgName : ACTIVITY_RESUME_BOOSTER@9
D/NearbyUtils(15128): clear nearby caches
E/cutils  (  213): Failed to mkdirat(/storage/extSdCard/Android): Read-only file system
W/Vold    (  213): Returning OperationFailed - no handler for errno 30
D/KeyguardUpdateMonitor( 1015): sendKeyguardVisibilityChanged(true)
D/KeyguardUpdateMonitor( 1015): handleKeyguardVisibilityChanged(1)
W/ContextImpl(15128): Failed to ensure directory: /storage/extSdCard/Android/data/com.sec.android.gallery3d/cache
I/Gallery_Performance(15128): Gallery onDestroy End
</code></pre>