7

I've created a prototype application for Android using kivy. It has compiled in buildozer and I've uploaded in to an Android device.

But I'm nor sure where to put app dependent files like the ini file, images database etc.

Any help greatly appreciated

[EDIT 2020 07 25]

When I asked this question (many moons ago) I was new to kivy and the whole idea of buildozer.

What I didn't realise and what isn't obvious to a beginner (witness the number of times this question has been viewed) and which @inclement's answer does not address, is that Buildozer wraps the whole python/kivy project into a single file which can include all of your static data. So you just need to make sure your buildozer spec picks them up.

Psionman
  • 3,084
  • 1
  • 32
  • 65

2 Answers2

2

You can arrange them to taste - as long as you tell buildozer to include them apk (i.e. by setting the file types, directories etc to be included) and access them with relative paths in your code, they will work the same way on the device.

The ini file may be an exception, I'm not sure offhand where kivy tries to load it from (but it may be somewhere in the external data dir). If putting it in the same directory as main.py doesn't work, maybe you could load it manually with a relative path, or if it has just a few values then you could set them in the main.py file.

inclement
  • 29,124
  • 4
  • 48
  • 60
  • Thanks inclement. Yes all my coding uses relative directories. But on the android device, relative to where? The sd card? – Psionman Apr 28 '15 at 15:29
  • 1
    To the python script - if the relative directories work on your pc, and your files are included properly by buildozer, they will also work on android. – inclement Apr 28 '15 at 15:57
  • Yes. But I'm not loading python script to the android it's an APK file – Psionman Apr 28 '15 at 17:02
  • Your main.py will be run just the same way (as far as is important) in the APK, and your local folder structure will be retained so you can reference assets in the same way. – inclement Apr 28 '15 at 17:09
0

It worked while I was using the pygame module, I haven't tried it with other modules, but maybe it works.

Folder where buildozer pulls files:

/data/data/package domain.package name /files/app/"

Example

buildozer.spec:
title = application
package.name = myapp
package.domain = org.test

main.py:

import os , sys
import pygame
path = "/data/data/org.test.myapp/files/app"
image = pygame.image.load(path+"image.jpg")

This command line does not work without converting to apk but it works fine when translated

The folder path will only be valid when running on android but... ----->

maybe this will help: ----> https://youtu.be/XQTIllli6js

and this: https://github.com/Sahil-pixel/Pygame-for-android/tree/main

DARKTITAN
  • 35
  • 4