I am using Android studio 3 with gradle. I need load a *.tmx-file (map for my game) with tinyxml2 library. My *.tmx-file is located in app/src/main/assets/ folder. But when I do:
I get error in debuger XML_ERROR_FILE_NOT_FOUND. I want create a cross-platform game. I know that SDL2 do some magic when access files from assets folder of android app. How can I load files for tinyxml2 from assets folder with help of SDL2?
The files in the assets folder that are packaged in the app and cannot be accessed normally via the filesystem.
In this case you need to load the file via the SDL file I/O api (https://wiki.libsdl.org/CategoryIO) and it will take care of reading the file from the APK (and possibly decompressing it) automatically.
Hopefully your xml library has a way to feed in the raw bytes or a string etc. instead of a file path. Another option is to extract the file to the applications private data dir and then use the standard filesystem apis.
@JonnyD, I get rwops equal null. What is the location of assets folder in Android studio gradle project? I suppose it is something wrong with assets folder location.