我在我的应用程序中使用 FragmentActivity 和几个片段。这些片段中的每一个都包含一个图像和一些带有动画的文本。当用户在屏幕上滑动时,片段会发生变化。
现在我已经为此工作了 10 天,并在具有不同 Android 版本的不同设备上测试了 FragmentActivity。从过去 10 天开始我一直坚持这一点的原因是我遇到了崩溃
Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 27830 (ple.myfragexample)
现在,仅当我特别在 Android 4.1.2 上测试 FragmentActivity 时才会出现此错误。它可以在 Android 2.3.3、4.0.3、4.0.4、4.2 甚至 2.2 上正常运行。错误日志如下:
08-07 14:34:13.843: D/dalvikvm(27830): GC_FOR_ALLOC freed 3845K, 14% free 35407K/40903K, paused 4ms, total 14ms
08-07 14:34:13.848: I/dalvikvm-heap(27830): Grow heap (frag case) to 39.590MB for 3932176-byte allocation
08-07 14:34:13.878: D/dalvikvm(27830): GC_CONCURRENT freed 3K, 5% free 39244K/40903K, paused 11ms+4ms, total 30ms
08-07 14:34:13.928: D/dalvikvm(27830): GC_FOR_ALLOC freed 0K, 5% free 39244K/40903K, paused 16ms, total 16ms
08-07 14:34:13.928: I/dalvikvm-heap(27830): Forcing collection of SoftReferences for 8847376-byte allocation
08-07 14:34:13.953: D/dalvikvm(27830): GC_BEFORE_OOM freed 9K, 5% free 39235K/40903K, paused 24ms, total 24ms
08-07 14:34:13.953: E/dalvikvm-heap(27830): Out of memory on a 8847376-byte allocation.
08-07 14:34:13.953: I/dalvikvm(27830): "main" prio=5 tid=1 RUNNABLE
08-07 14:34:13.953: I/dalvikvm(27830): | group="main" sCount=0 dsCount=0 obj=0x41ea8508 self=0x41e989c8
08-07 14:34:13.953: I/dalvikvm(27830): | sysTid=27830 nice=0 sched=0/0 cgrp=apps handle=1074937648
08-07 14:34:13.953: I/dalvikvm(27830): | schedstat=( 2591504030 1697770606 13588 ) utm=221 stm=38 core=0
08-07 14:34:13.953: I/dalvikvm(27830): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
08-07 14:34:13.953: I/dalvikvm(27830): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:625)
08-07 14:34:13.953: I/dalvikvm(27830): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:478)
08-07 14:34:13.953: I/dalvikvm(27830): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:781)
08-07 14:34:13.953: I/dalvikvm(27830): at android.content.res.Resources.loadDrawable(Resources.java:1963)
08-07 14:34:13.953: I/dalvikvm(27830): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
08-07 14:34:13.953: I/dalvikvm(27830): at android.view.View.<init>(View.java:3449)
08-07 14:34:13.953: I/dalvikvm(27830): at android.widget.ImageView.<init>(ImageView.java:114)
08-07 14:34:13.953: I/dalvikvm(27830): at android.widget.ImageView.<init>(ImageView.java:110)
08-07 14:34:13.953: I/dalvikvm(27830): at java.lang.reflect.Constructor.constructNative(Native Method)
08-07 14:34:13.953: I/dalvikvm(27830): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
08-07 14:34:13.953: I/dalvikvm(27830): at android.view.LayoutInflater.createView(LayoutInflater.java:587)
08-07 14:34:13.953: I/dalvikvm(27830): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
08-07 14:34:13.953: I/dalvikvm(27830): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
08-07 14:34:13.953: I/dalvikvm(27830): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
08-07 14:34:13.953: I/dalvikvm(27830): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
08-07 14:34:13.953: I/dalvikvm(27830): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
08-07 14:34:13.953: I/dalvikvm(27830): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
08-07 14:34:13.953: I/dalvikvm(27830): at com.example.myfragexample.pages.Page6.onCreateView(Page6.java:52)
08-07 14:34:13.953: I/dalvikvm(27830): at android.support.v4.app.Fragment.performCreateView(Fragment.java:1460)
08-07 14:34:13.953: I/dalvikvm(27830): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:911)
08-07 14:34:13.953: I/dalvikvm(27830): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1088)
08-07 14:34:13.953: I/dalvikvm(27830): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
08-07 14:34:13.953: I/dalvikvm(27830): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1444)
08-07 14:34:13.953: I/dalvikvm(27830): at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:429)
08-07 14:34:13.953: I/dalvikvm(27830): at android.os.Handler.handleCallback(Handler.java:615)
08-07 14:34:13.953: I/dalvikvm(27830): at android.os.Handler.dispatchMessage(Handler.java:92)
08-07 14:34:13.953: I/dalvikvm(27830): at android.os.Looper.loop(Looper.java:137)
08-07 14:34:13.953: I/dalvikvm(27830): at android.app.ActivityThread.main(ActivityThread.java:4921)
08-07 14:34:13.953: I/dalvikvm(27830): at java.lang.reflect.Method.invokeNative(Native Method)
08-07 14:34:13.953: I/dalvikvm(27830): at java.lang.reflect.Method.invoke(Method.java:511)
08-07 14:34:13.953: I/dalvikvm(27830): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027)
08-07 14:34:13.953: I/dalvikvm(27830): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
08-07 14:34:13.953: I/dalvikvm(27830): at dalvik.system.NativeStart.main(Native Method)
08-07 14:34:13.953: A/libc(27830): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 27830 (ple.myfragexample)
我在互联网上进行了很多搜索并尝试了很多关于此的事情,但是,我的 Fragments 在任何其他版本的 Android 设备上的工作变得更加流畅,但仅限于 Android 4.1.2。我也尝试使用Universal Image Loader,但它仍然因致命信号 11 而崩溃。我使用 Universal Image Loader 时得到的错误日志如下:
08-07 14:20:03.678: D/dalvikvm(27268): GC_FOR_ALLOC freed 3857K, 32% free 33002K/48455K, paused 31ms, total 34ms
08-07 14:20:03.678: I/dalvikvm-heap(27268): Grow heap (frag case) to 37.241MB for 3932176-byte allocation
08-07 14:20:03.708: D/dalvikvm(27268): GC_FOR_ALLOC freed 5K, 24% free 36837K/48455K, paused 28ms, total 28ms
08-07 14:20:03.738: D/dalvikvm(27268): GC_CONCURRENT freed <1K, 24% free 36837K/48455K, paused 11ms+2ms, total 30ms
08-07 14:20:03.848: D/dalvikvm(27268): GC_FOR_ALLOC freed <1K, 24% free 36837K/48455K, paused 17ms, total 17ms
08-07 14:20:03.848: I/dalvikvm-heap(27268): Forcing collection of SoftReferences for 8847376-byte allocation
08-07 14:20:03.883: D/dalvikvm(27268): GC_BEFORE_OOM freed 9K, 24% free 36828K/48455K, paused 32ms, total 35ms
08-07 14:20:03.883: E/dalvikvm-heap(27268): Out of memory on a 8847376-byte allocation.
08-07 14:20:03.888: I/dalvikvm(27268): "pool-1-thread-1" prio=4 tid=12 RUNNABLE
08-07 14:20:03.888: I/dalvikvm(27268): | group="main" sCount=0 dsCount=0 obj=0x4293af60 self=0x4f6c9470
08-07 14:20:03.888: I/dalvikvm(27268): | sysTid=27283 nice=10 sched=0/0 cgrp=apps/bg_non_interactive handle=1098606736
08-07 14:20:03.888: I/dalvikvm(27268): | schedstat=( 2735922613 2106917058 1146 ) utm=266 stm=7 core=0
08-07 14:20:03.888: I/dalvikvm(27268): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
08-07 14:20:03.888: I/dalvikvm(27268): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:625)
08-07 14:20:03.888: I/dalvikvm(27268): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:478)
08-07 14:20:03.888: I/dalvikvm(27268): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:781)
08-07 14:20:03.888: I/dalvikvm(27268): at android.content.res.Resources.loadDrawable(Resources.java:1963)
08-07 14:20:03.888: I/dalvikvm(27268): at android.content.res.Resources.getDrawable(Resources.java:672)
08-07 14:20:03.888: I/dalvikvm(27268): at com.nostra13.universalimageloader.core.download.BaseImageDownloader.getStreamFromDrawable(BaseImageDownloader.java:184)
08-07 14:20:03.888: I/dalvikvm(27268): at com.nostra13.universalimageloader.core.download.BaseImageDownloader.getStream(BaseImageDownloader.java:84)
08-07 14:20:03.888: I/dalvikvm(27268): at com.nostra13.universalimageloader.core.decode.BaseImageDecoder.getImageStream(BaseImageDecoder.java:82)
08-07 14:20:03.888: I/dalvikvm(27268): at com.nostra13.universalimageloader.core.decode.BaseImageDecoder.decode(BaseImageDecoder.java:68)
08-07 14:20:03.888: I/dalvikvm(27268): at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.decodeImage(LoadAndDisplayImageTask.java:284)
08-07 14:20:03.888: I/dalvikvm(27268): at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.tryLoadBitmap(LoadAndDisplayImageTask.java:243)
08-07 14:20:03.888: I/dalvikvm(27268): at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.run(LoadAndDisplayImageTask.java:125)
08-07 14:20:03.888: I/dalvikvm(27268): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
08-07 14:20:03.888: I/dalvikvm(27268): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
08-07 14:20:03.888: I/dalvikvm(27268): at java.lang.Thread.run(Thread.java:856)
08-07 14:20:03.888: A/libc(27268): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 27283 (pool-1-thread-1)
现在,我知道这里也有很多关于致命信号 11 的问题,但我很担心和困惑,因为我只在 Android 4.1.2上而不是在任何其他 Android 版本上遇到这种崩溃。