I have Acra in my app to report on crashes(I will be removing it in
favor of the market one soon). I've recently changed the form that it
posts to during an upgrade(so the new app version will post to the new
form, the old version will remain on the old form). However, I've
witnessed old code, throwing an exception about resources being null,
being reported to the new form. Acra attaches an uncaughtException
Handler to the application class. In this case, since I've switched
destination forms, it implies that Android is replacing the code in
place in the same process.  The exceptions I get are in the old code,
usually accessing resources from the context.

An example is:
onCreate() in my launch activity sets up a tab host. It assigns a
selectorDrawable to the tab(an xml resource, referring to 2 valid png
files, all in the drawable directory). It gets a ResourceNotFound
Exception - stack trace at the end. The line numbers indicate it is
being thrown in old code. However, the user has installed the new
version since I see the exception on the new form. It seems that there
is a race condition during upgrades where pieces of the old app are
still around while the new one is being placed in.

I've also seen very similar things in a Service that has an AsyncTask
that gets the AppWidgetManager.getInstance(this). In this case, it
throws an NPE in there - stack also at end..

In the end, a solution would be to enforce a new process for the new
instance of the app. Is this possible? If that is what happens, how is
the code being mingled at runtime? Could the user be launching my app
while it is "installing", and thus get pieces of the old one still?

Thanks
Robert

Stack trace showing the tab host failure:
Caused by: android.content.res.Resources$NotFoundException: File
res/drawable/ic_tab_alert.xml from drawable resource ID #0x7f020010
at android.content.res.Resources.loadDrawable(Resources.java:1725)
at android.content.res.Resources.getDrawable(Resources.java:590)
at com.zomut.watchdog.library.Main.onCreate(Main.java:168)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2701)
... 11 more
Caused by: java.lang.NullPointerException
at 
android.graphics.drawable.DrawableContainer$DrawableContainerState.addChild(DrawableContainer.java:349)
at 
android.graphics.drawable.StateListDrawable$StateListState.addStateSet(StateListDrawable.java:265)
at 
android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:173)
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:796)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java:737)
at android.content.res.Resources.loadDrawable(Resources.java:1722)
... 15 more

Stack trace showing the AppWidget.getInstance() failure:
java.lang.NullPointerException
       at android.appwidget.AppWidgetManager.<init>(AppWidgetManager.java:230)
       at 
android.appwidget.AppWidgetManager.getInstance(AppWidgetManager.java:221)

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to