We register a broadcast receiver for packet reception or deletion.
But some users report crash reports as follows:
java.lang.RuntimeException: Unable to create application com.kc.security.MoSecurityApplication: java.lang.RuntimeException: getResources is null: dir - /data/app/com.cm.mg-1.apk, srcVal-1, srcVal-2 at android.app.LoadedApk.makeApplication(LoadedApk.java:495) at android.app.ActivityThread.handleCreateService(ActivityThread.java:2249) at android.app.ActivityThread.access$1600(ActivityThread.java:123) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1201) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:4424) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.RuntimeException: getResources is null: dir - /data/app/com.cm.mg-1.apk, srcVal-1, srcVal-2 at com.kc.security.b.ab.b(UpdateManager.java:69) at com.kc.security.b.ab.a(UpdateManager.java:112) at com.kc.security.MoSecurityApplication.onCreate(MoSecurityApplication.java:66) at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:969) at android.app.LoadedApk.makeApplication(LoadedApk.java:492) ... 11 more
It is not easy to see this disaster again. We think a lot about this problem. We get to delete the event, then the application context class, called its onCreate method, we do some initial work there, when we call getResouce (), it returns null. When you look deep inside the frameworks, we find that getReource locates the sourceDir String resource file in ApplicationInfo, and String - "/data/app/com.cm.mg-1.apk"> is the original apk and it no longer exists.
Perhaps this will happen when the user updates our application. In some way, "/data/app/com.cm.mg-1.apk" is deleted and replaced with "/data/app/com.cm.mg-2.apk" in any way, but the string "sourceDir" in ApplicationInfo is not updated.
I want to know what android does when updating.
source share