I have crash that in my app that I have never managed to reproduce myself but that I know happens occasionally because I can see that in the Google Analytics console.
The crash happens as the user launches the application. An exception is raised when I call setContentView in my Activity derived class
H:0kfgjhA== T:main RuntimeException(Unable to start activity ComponentInfo{com.mydomain·myapp/com.mydomain·myapp.activity.history.HistoryActivit) Cause: NotFoundException(Resource ID #0x7f020134) S:24 00:Resources:android.content.res.Resources.getValue:1274
01:Resources:android.content.res.Resources.getDrawable:797
02:Context:android.content.Context.getDrawable:402
03:ToolbarWidgetWrapper:com.android.internal.widget.ToolbarWidgetWrapper.setIcon:320
04:ActionBarOverlayLayout:com.android.internal.widget.ActionBarOverlayLayout.setIcon:738
05:PhoneWindow:com.android.internal.policy.impl.PhoneWindow.setDefaultIcon:1623
06:Activity:android.app.Activity.initWindowDecorActionBar:2139
07:Activity:android.app.Activity.setContentView:2154
09:MyActivity:com.mydomain·myapp.activity.MyActivity.onCreate:121
The resource that I set in the call to setContentView is an empty FrameLayout
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/content_frame">
</FrameLayout>
The resource that the Resource class cannot find is the application icon (ID #0x7f020134). That icon is only referenced at one place and that is in the manifest file
<application
android:name=".MyApplication"
android:allowBackup="false"
android:icon="@drawable/my_launcher_icon"
.../>
It seems as this defect appeared after we included the appcompat support library v7. That is done in the manifest file (in the dependencies section)
compile 'com.android.support:appcompat-v7:23.1.1'
Does anybody know anything about this problem? How can I fix it?
According to Google Analytics the crash seems to happen only on 5.0, 5.01 and 5.1.1 devices. And it is not a very frequent crash and it is very stochastic.
Thanks Ola, Sweden
Edit:
The oncreate function looks like this:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (android.os.Build.VERSION.SDK_INT >= 21) {
getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
}
setContentView(R.layout.activity_trackid);
}
You can add this line in application tag
android:theme="@style/AppTheme"
Like:
<application
android:theme="@style/AppTheme"
android:name=".MyApplication"
android:allowBackup="false"
android:icon="@drawable/my_launcher_icon"
/>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.