Toml and ConfigParser won't work on android, help!

37 views
Skip to first unread message

Claver Barreto

unread,
Mar 17, 2023, 1:01:20 PM3/17/23
to Kivy users support
Hello mates, so im trying to make this tutorial screen?dialog?popup? you name it. So basically i have a MDDialog popping out on the screen with a tutorial text.

At first i would get the text from an INI file "tutorial.ini" using python's ConfigParser, it works fine on my computer, the text is displayed, however when i try the app on my android mobile device, the app crash with a "NoSectionError".

So after failing a lot with ConfigParser, i decided to try with Toml, now with Toml i get a "FileNotFoundError", this one "FileNotFoundError: [Errno 2] No such file or directory: 'tutorial.toml'

here is the structure of my toml/INI file:

[gameconfig]

tutorialused = False

[gameinstruction]

instruction1 = "some text"

instruction2 = "some text 2"

Now as i said, with ConfigParser, it says that "configparser.NoSectionError: No section: 'gameconfig'".

With Toml i get the error "FileNotFoundError: [Errno 2] No such file or directory: 'tutorial.toml'

Any ideas why this is happening and hopefully how to fix it?

Elliot Garbus

unread,
Mar 17, 2023, 2:20:53 PM3/17/23
to kivy-...@googlegroups.com

I have not done any Android programming – so take this with a grain of salt.

 

Check the file locations, and make sure you can accesses them as expected.  Config parser is expecting file-like objects to read and write.

If you need to do anything Android specific the read/write the files, you could access the file as a textfile and parse using ConfigParser.read_string()

You could use the python io module to write to a StringIO object in the ConfigParser.write(), and the save the string with the Android specific code.

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/10d979a3-8208-4976-94a6-6ca16fdf8fafn%40googlegroups.com.

 

Robert

unread,
Mar 17, 2023, 4:09:07 PM3/17/23
to Kivy users support
There is nothing special about Config on Android.

Two things that are different about using and building for Android, I'd look at these:

The android file system is organized in a different way to the desktop.
If you want to package the .ini you have to specify it in buildozer.spec 

Claver Barreto

unread,
Mar 18, 2023, 2:22:39 AM3/18/23
to Kivy users support
hello mate. im sorry for the late reply, i've underestimated how tired i was and slept with my computer on. So i tried with the StringIO method, and it gives a different error, which is the FileNotFoundError, which is the error that appeared when i used toml

Claver Barreto

unread,
Mar 18, 2023, 2:24:16 AM3/18/23
to Kivy users support
hello mate, sorry for the late reply. I did indeed not specify the INI format in buildozer.spec, i thought that since configparser is a built-in module, it wouldn't require me to do it. let me try this.

Claver Barreto

unread,
Mar 18, 2023, 5:03:43 AM3/18/23
to Kivy users support
So the solution was indeed adding the .ini to the buildozer.spec, after that, i did "buildozer appclean" and made a new build and it worked. thank you mates.
Reply all
Reply to author
Forward
0 new messages