Android Manifest permissions not compiling (DEF-1916)

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.

Has anyone gotten this working yet?

I’m not sure I understand the problem? Are you unable to install an Android build using the default manifest file? Or are you using a custom manifest?

Post the custom manifest here in a zip.

I’m not really using a custom manifest.

I’m just using the one generated by defold and explicitly defining it inside of the field in game.project.

I can generate and install an APK and it runs completely fine.

however it asks for no permissions prior to installing

and a result sys.save and sys.load don’t work

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.

Its the one generated by Defold.

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.

Yes. First, I tried it without defining a custom manifest.

The app works as expected, except it does not ask for any permissions nor is it granted any permissions.

Second I tried defining the manifest (By using the one generated by defold) then building the APK again.

it had no effect.

This prevents me from saving the player’s best score.

I’m running the latest version of Marshmallow on a Nexus 6P

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))
1 Like

I got the hint.

I replaced

 sys.save("save_file", save_data)

with

local success = sys.save(sys.get_save_file("save_file", "save_data"), save_data)

and for loading

local save_data = sys.load("save_file")
local save_data = sys.load(sys.get_save_file("save_file", "save_data"))

works perfectly now, thanks a ton!

3 Likes

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.

2 Likes