When I compile my program for android and try to install, the file asks for no additional permissions, such storage access permissions is not asked for even though inside of the android manifest it specifies those permissions.
I’ve tried using a custom manifest and including it in the game.project file to no avail.
If you’re not making any changes to the AndroidManifest file then there’s no need to have it as a file on disk and point to it in game.project. Where did you get the manifest file from by the way?
Are you using the manifest generated when you build Android builds? You should be using that one if you need to make custom changes, and not the one that’s in the plugins folder somewhere.
To clarify are normal Android builds working without defining a custom manifest?
What is the model of your device and Android version?
Could anyone else test this to see if permissions are working properly with Android builds right now? I do not have an Android device handy at the moment.
Ok, so since Android Marshmallow the permissions system has changed significantly. When you install an app that targets API level 23 you will no longer get a long list of permissions when installing the app. Instead the app is supposed to request what Google calls “dangerous permissions” at run-time. We do not do this at this time. On the other hand, the WRITE_EXTERNAL_STORAGE is since API version 19 no longer needed to write to the application specific directories where it is recommended that you save data such as high scores.
My question now is if you have tried saving your highscore or have you simply noticed that the permission is never asked for and assumed that it will not work?
If you have tried saving your highscore and it did not work, then exactly how did you try to do this? Are you using sys.get_save_file() in combination with sys.save() or io.write()?
I’ve simply run the game as a program on the desktop. Works fine. Saves score to file and loads from file with ease.
The same code does not save on mobile.
I verified by checking the /Android/data/com.package.extension/files directory to see if it had saved but simply was not loading.
But there was no file present. Here is my code.
The scope of both is within a on_message function
SAVING DATA
local save_data = {}
if self.score > self.best_score then
gui.set_enabled(self.best_score_icon, true)
save_data["score"] = self.score
else
save_data["score"] = self.best_score
end
if next(save_data) == nil then
--no data to save
else
sys.save("save_file", save_data)
end
LOADING DATA
self.score = 0
gui.set_text(self.score_node, tostring(self.score))
--load best score
local save_data = sys.load("save_file")
if next(save_data) == nil then
self.best_score = 0
else
self.best_score = save_data["score"]
end
gui.set_text(self.best_score_node, tostring(self.best_score))
Excellent! Using sys.save(“save_file”, save_data) on Android will try to write to a folder outside of the application-specific folders, and this requires the WRITE_EXTERNAL_STORAGE permission. You should always use sys.get_save_file() first to get a “safe” location to save/load data from.