再次提出更多细节问题。 我们最近切换到使用AppCompatActivity而不是FragmentActivity,现在一些设备随机崩溃,出现以下错误。不知道为什么会这样。
堆栈跟踪显示它在调用AppCompatActivity的super.onCreate()时崩溃。
TemplateField
这是结构: ItemPhotoViewer onCreate():
<asp:GridView ID="GridView1" runat="server">
<Columns>
<asp:TemplateField ItemStyle-CssClass="hidden">
<ItemTemplate>
<span><%# Eval("ObjectiveID") %></span>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<style type="text/css">
.hidden span {
display: none;
}
</style>
AbstractActivity onCreate():
Fatal Exception: java.lang.OutOfMemoryError: Failed to allocate a 16008012 byte allocation with 4277152 free bytes and 4MB until OOM
at dalvik.system.VMRuntime.newNonMovableArray(VMRuntime.java)
at android.graphics.BitmapFactory.nativeDecodeAsset(BitmapFactory.java)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:856)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:675)
at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:703)
at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:733)
at android.graphics.drawable.BitmapDrawable.updateStateFromTypedArray(BitmapDrawable.java:779)
at android.graphics.drawable.BitmapDrawable.inflate(BitmapDrawable.java:741)
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:2549)
at android.graphics.drawable.LayerDrawable.inflateLayers(LayerDrawable.java:254)
at android.graphics.drawable.LayerDrawable.inflate(LayerDrawable.java:164)
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:2549)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java:2320)
at android.content.res.Resources.loadDrawableForCookie(Resources.java:4210)
at android.content.res.Resources.loadDrawable(Resources.java:4089)
at android.content.res.Resources.getDrawable(Resources.java:2005)
at android.content.res.Resources.getDrawable(Resources.java:1987)
at android.content.Context.getDrawable(Context.java:464)
at android.support.v4.content.ContextCompat.android.support.v4.content.ContextCompatApi21.getDrawable(SourceFile:3026)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(SourceFile:200)
at android.support.v7.widget.TintTypedArray.getDrawableIfKnown(SourceFile:81)
at android.support.v7.app.AppCompatDelegateImplBase.(SourceFile:127)
at android.support.v7.app.AppCompatDelegateImplV9.(SourceFile:147)
at android.support.v7.app.AppCompatDelegateImplV11.(SourceFile:27)
at android.support.v7.app.AppCompatDelegateImplV14.(SourceFile:53)
at android.support.v7.app.AppCompatDelegateImplV23.(SourceFile:29)
at android.support.v7.app.AppCompatDelegate.create(SourceFile:203)
at android.support.v7.app.AppCompatDelegate.create(SourceFile:185)
at android.support.v7.app.AppCompatActivity.getDelegate(SourceFile:525)
at android.support.v7.app.AppCompatActivity.onCreate(SourceFile:74)
at com.dubizzle.horizontal.activities.AbstractActivity.onCreate(SourceFile:98)
at com.dubizzle.horizontal.activities.ItemPhotoViewer.onCreate(SourceFile:68)
at android.app.Activity.performCreate(Activity.java:6876)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3207)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3350)
at android.app.ActivityThread.access$1100(ActivityThread.java:222)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1795)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7229)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
答案 0 :(得分:-2)
添加
android:largeHeap="true"