mapbox-unity-sdk
mapbox-unity-sdk copied to clipboard
Android Target API Level 31 fails on starting LocationProvider/TelemetryPlugin
For Android new apps must target API Level 31 at minimum to be submitted in Google Play. For already exisiting apps updates are always restricted to that since November 1th.
But the telemtry plugin seems to fail in this case based on the creation of a pending intent missing "FLAG_IMMUTABLE".
Anyone around with a solution to this?
2022.12.23 12:13:16.783 19432 19454 Error Unity Error initializing telemetry: UnityEngine.AndroidJavaException: java.lang.IllegalArgumentException: com.nmy.unseen: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
2022.12.23 12:13:16.783 19432 19454 Error Unity Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
2022.12.23 12:13:16.783 19432 19454 Error Unity at UnityEngine.AndroidJNISafe.CheckException () [0x00000] in <00000000000000000000000000000000>:0
2022.12.23 12:13:16.783 19432 19454 Error Unity at UnityEngine.AndroidJNISafe.CallBooleanMethod (System.IntPtr obj, System.IntPtr methodID, UnityEngine.jvalue[] args) [0x00000] in <00000000000000000000000000000000>:0
2022.12.23 12:13:16.783 19432 19454 Error Unity at UnityEngine.AndroidJavaObject._Call[ReturnType] (System.String methodName, System.Object[] args) [0x00000] in <00000000000000000000000000000000>:0
2022.12.23 12:13:16.783 19432 19454 Error Unity at Mapbox.Unity.MapboxAccess.ConfigureTelemetry () [0x00000] in <00000000000000000000000000000000>:0
2022.12.23 12:13:16.783 19432 19454 Error Unity at Mapbox.Unity.MapboxAccess.SetConfiguration (Mapbox.U
I know we are late on this but in case anyone finds this issue; we are currently looking into this and pushed a few changes on MME branch here;
https://github.com/mapbox/mapbox-unity-sdk/tree/mme
if you give it a try, please let us know if that solves the issue or if any further changes/fixes are required.
after some further tests, I realized that branch isn't ready yet, I'll post an update here when the remaining issues are fixed.
@Markovicho after some more tests and improvements, I pushed the proposed fix here; https://github.com/mapbox/mapbox-unity-sdk/tree/androidEventsFix
Hi @brnkhy,
I have exactly the same problem as @Markovicho. Can you (or anyone) please explain - in simple terms, how I can correct this Mapbox error. Can you please explain how I can incorporate the above 'fix' into my Unity project. I have already tried manually updating the files - but this leads to other errors:
2024/07/01 13:45:11.421 20078 20097 Error Unity Error initializing telemetry: UnityEngine.AndroidJavaException: java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/core/content/ContextCompat; 2024/07/01 13:45:11.421 20078 20097 Error Unity at UnityEngine.AndroidJNISafe.CheckException () [0x00000] in <00000000000000000000000000000000>:0 2024/07/01 13:45:11.421 20078 20097 Error Unity at UnityEngine.AndroidJNISafe.CallBooleanMethod (System.IntPtr obj, System.IntPtr methodID, UnityEngine.jvalue[] args) [0x00000] in <00000000000000000000000000000000>:0 2024/07/01 13:45:11.421 20078 20097 Error Unity at UnityEngine.AndroidJavaObject._Call[ReturnType] (System.String methodName, System.Object[] args) [0x00000] in <00000000000000000000000000000000>:0 2024/07/01 13:45:11.421 20078 20097 Error Unity at Mapbox.Unity.Telemetry.TelemetryAndroid.SendTurnstile () [0x00000] in <00000000000000000000000000000000>:0 2024/07/01 13:45:11.421 20078 20097 Error Unity at Mapbox.Unity.MapboxAccess.ConfigureTelemetry () [0x00000] in <00000000000000000000000000000000>:0 2024/07/01 13:45:11.421 20078 20097 Error Unity at Mapbox.Unity.MapboxAccess+<TelemetryDelay>d__17.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 2024/07/01 13:45:11.421 20078 20097 Error Unity at Mapbox.Unity.Utilities.Runnable+Routine.MoveNext () [0x00000] in <00000000000000000000000000000000>:0
Anyone around with a solution?
I got the same error, but updating the main template doesn't work for me. Are there any updates on this issue? Or other things I could try?
@DutchRose-Jochem at this point I would suggest trying v3 alpha. you can find about it here towards the end of the ticket; https://github.com/mapbox/mapbox-unity-sdk/issues/1912
Thanks, I will check that out! Really good to hear that the SDK is finally getting an update again!
I think I've made it work, the telemetry error went away.
- I opened the SDK project with the fix
- I erased the AR folders (for my use case I didn't need them)
- Exported MapBox folder as unityPackage
- In my own project I cleared MapBox Plugins folder(though I should have probably erased the whole old MapBox)
- Imported this into my project, overwriting the previous version
- I edited the mainTemplate.gradle of my current project, decided to add all dependencies from the SDK project, even though I started just with these:
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.5'
implementation group: 'com.squareup.okhttp3', name: 'okhttp', version: '4.9.0'
implementation group: 'commons-io', name: 'commons-io', version: '2.5'
And just after I added those, it already worked. Note that my mainTemplate also already contained this:
implementation 'androidx.core:core:1.12.0'
And this from Firebase:
implementation 'com.google.android.gms:play-services-base:18.5.0' // Assets/Firebase/Editor/AppDependencies.xml:17
I noticed MapBox uses play-services-location, so maybe I'm still missing something. In any case the functionality in my case seems like it was before the update, and the telemetry error is gone.
The above issue with contextCompat feels like maybe not including this dependency, which is in the Mapbox SDK project?
runtimeOnly group: 'androidx.appcompat', name: 'appcompat', version: '1.6.1'
But no clue why I'm not getting it, because I didn't even get to add this into my template.
@rainbowcreatures I would highly suggest checking new v3 (mentioned few posts above) and see if it works for you as that'll be the version we'll maintain, support and update for future api level issues.
Thanks! I've read about V3...however we were just before release and I didn't want to delay any longer by migrating to a new version.