Unity Bug Fix - Problem (Android 6) - Urgent

Hi,

So I downloaded the latest 4.6.9p2 release to take advantage of a few iOS fixes as always
(Don’t expect much from Android)

Changes

  • Android: Android 6.0 - Limit targetSdk to 22 because of permission handling issues for Marshmallow (case 739831, 732504).

So now I need to update my application on the Google Play store with a bug fix for customers, this is the error I get:

This configuration cannot be published for the following reason(s):

  • It is forbidden to downgrade devices which previously used M permissions (target SDK 23 and above) to APKs which use old style permissions (target SDK 22 and below). This occurs in the change from version 21 (target SDK 23) to version 23 (target SDK 22).

So how does Unity plan to help with this issue and existing customers who wish to update Apps?
This fix is not ideal, please developer respond.

EDIT: As I thought downgrading to 4.6.9 fixed the issue, but I wish for proper solution as there are Android 6 bugs within 4.6.9 and you still need support 4.6.9 for another month!

Juste released our game and…Using targetSdkVersion 23…Just great…Watching for some informations from Unity and/or Google on this point…

I think the issue is not for new releases as this be okay, just if someone has a existing release and then they upgrade there App in the future, this problem I had…I definitely looking for some kind of explanation to this…

1 Like

Humm, you may be right but i can’t be sure if everything is managed correctly “by default” if the fresh installation is on target 23 SDK.

Or maybe i have misunderstood something. I completely understand your point of view, correct me if i’m right, but you are concerned about user, using a previous version of the app with targetSDK 22 and then upgrading to targetSDK 23, which has a complete different system of permission.

But even for fresh install on targetSDK 23, is everything about the permissions, managed correctly “by the time” of use ? Does Unity need to implement something to “Ask acccess” to a permission to the user, as it may have revoked a previous granted permission by denying it explicitly or just by not using the application, as i have read that there is a sort of process like this now.

I want to avoid problems of users like “Ho my save game just disappear!” because internally the system revoked the “WRITE EXTERNAL STORAGE PERMISSION”, and that Unity may not have managed to Re-ASK for this permission.

Of course theses changes only affect Android 6.0 but…I think that “Something must be done” about it, and maybe on Unity side, but i can’t be sure.

1 Like

Most likely Unity 4.6 will never support Android M as the target version, the changes needed to make it fully M target compatible are just too many to be introduced this late in the life cycle. It is as far as we know still compatible with Android M as long as you keep targetSDKVersion below 23 - this is why we capped the SDK version by default.

If you really need to target Android M and the only incompatibility you see is with runtime permissions, then what you can do is write a plugin that takes care of the runtime permissions on startup. Basically on startup you make sure to ask for any dangerous permissions listed in the AndroidManifest and then you bump targetSDKVersion to 23.

If I have time later maybe I can compile a small code sample for you.

Something like this - Grant me runtime permissions. · GitHub

I didn’t actually run the code so I can’t guarantee it works :wink:

As our game has been released with targetSDKVersion 23, using Unity 4.6.9p1, i think we don’t have many choice for Android 6.0, as we can’t re-upload an new Build with a lower SDK, isn’t it ?

However, i will take a look and test on your code, if we can manage the worst scenarios with this.

I think I understand, Just so we are clear, on Unity 4.6.9 final release I have set my game to Minimum API level 15, reason for this was so I can target more devices and customers.

Now when I load the same project in Unity 4.6.9p2 not changing anything but fixing a bug for the game, I get the error from Google play. So you telling me this expected?

If I target SDK23 minim API, then I lose hell lot customers, or I got this completely wrong and noob mistake?

Correct me if i’m wrong, but you will never have any problem if your customer is on previous Android version, as older API Level will be used internally. You may just have some issue on Marshmallow (Android 6.0 / API Level 23) if you use some critical permissions that can be disabled by the user or by time inactivity (not totally sure about this).

The good thing in my opinion is:

  • set minimum SDK as low as you can: On my project its “API Level 9” actually.
  • set targetSDK to the newest, as you have already published your game on “API Level 23”.
  • Add the Java code that check permissions for Android 6.0. It only have to be checked on this SDK level, because older SDK grant permissions always at install time, and permissions cannot be revoked manually.

Actually, i’m developping a Unity Plugin thanks to Bitter code snippet, that check and ask permissions if required, and call a success callback or fail callback in C#, this way you can manage Android 6.0 (Marshmallow) behavior the way you prefer. Older SDK version will so always return success.

I plan to set the plugin compatible from API Level 9 minimum (Android 2.3.1), thanks to the Android Support V4 Library, and i will share it as a free asset.

2 Likes

Thanks for the detailed reply, where do I set the targetSDK, so somehow between 4.6.9 and 4.6.9p2 Unity changes the settings for this?

You can’t change it by the Unity Editor GUI (but you can change the Minimum via the GUI). I always set targetSDK with the AndroidManifest.xml file from my Unity Project.

But in my opinion, there is no need to go on Unity 4.6.9p2 if you only target Android.
From my own side, i have Unity 4.6.9p1 for Android, and Unity 4.6.9p2 on my Mac Mini for iOS.

However, 4.6.9p1 or 4.6.9p2, the problem is still the same, if you have send on Google Play a targetSDK 23, you will have to manage theses possible dynamic permissions for Android.

Still working on my plugin, cause i have some issue.

I understand, but im just getting confused i have not changed anything between the 4.6.9
Build and the patch 2 build… So why has google play thrown this error to me - so its something Unity is doing… Maybe im not getting something.hence my first posting… I think there two things being discussed in the thread…

Yes maybe Unity is capping the targetSDK. To be sure, after any APK build, you can go to Temp/StagingArea folder and look what is the targetSDK setted in the final AndroidManifest.xml…Or if you want to be 100% sure, take a look at the metadata of your apk file with aapt -d badging “yourapk.apk” .

Perfect, thank you, will do some further tests tommorow and compare the .apks created in the different versions of Unity…

Yes, if you don’t explicitly set targetSDKVersion Unity will cap it to 22.

Still working on my plugin. It seem that something go wrong, and it seem that the “catch” code is called, however, its very difficult to debug a Android Module from Unity as you can’t!

So i will try to test the module behavior with a real Android Test App with Android Studio…So i still have to do some test…

FYI, we are currently discussing putting a version of this code in Unity 4. However, I can’t make any promises since it will require some non-trivial changes to the life cycle.

In wich form do you think this will be managed on Unity 4 ? Automatically at app start, or will i need to register a callback in the App to take my own decision of “What to do then” if permission granted or not ?

The plan is to automatically ask for all permissions on startup.

Ah I see, for some reason was not aware of this…Think the minimum API confused me with target SDK. In this case I think I be able solve my issues : Cheers for all the feedback.