Quantcast
Channel: Questions in topic: "crash"
Viewing all articles
Browse latest Browse all 2383

How to permanently set the ID of resources in R.java?

$
0
0
**TL;DR** APKs generated with Unity 2017.4 have different IDs in the R.java file that Unity generates compares to previous versions - this can cause crashes when players update to an APK that was built with a new version of Unity.

*Is there a way to set the IDs of those resources so it won't change the next time we upgrade?*

**The long story** After upgrading our Unity version from 2017.3 to 2017.4.25, we had a lot of these showing up:
Fatal Exception: android.app.RemoteServiceException: Bad notification posted from package com.xxx.xxx: Couldn't create icon: StatusBarIcon(icon=Icon(typ=RESOURCE pkg=com.xxx.xxx id=0x7f020088) visible user=0 )
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1906)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:164)
       at android.app.ActivityThread.main(ActivityThread.java:7000)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:441)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)

I found that it happens when a notification was scheduled by the version **before** the Unity upgrade and shown after the Unity upgrade. The reason for the crash is that the ID of some icon (specifically expandActivityOverflowButtonDrawable) has changed between the APK from Unity 2017.3 and the APK from Unity 2017.4.

This ID can be found at `Temp/gradleOut/build/generated/not_namespaced_r_class_sources/debug/processDebugResources/r/com/xxx/xxx/R.java` in the Unity project folder after building the APK, or at `res/values/public.xml` if you decode the APK with apktool. Before Unity 2017.4 it was: and after upgrading to Unity 2017.4 it is:

Viewing all articles
Browse latest Browse all 2383

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>