应用程序在Android M上通过Inflate Exception崩溃

时间:2015-11-24 23:26:43

标签: android crash android-6.0-marshmallow inflate-exception

我的应用程序在所有经过测试的Android版本上运行良好,它只是在Android M上使用InflateException启动时直接崩溃。这是堆栈跟踪:

11-25 10:17:05.690 E/AndroidRuntime: FATAL EXCEPTION: main
                                 Process: abcdef, PID: 2474
                                 java.lang.RuntimeException: Unable to start activity ComponentInfo{abcdef/abcdef.SplashScreen}: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class <unknown>
                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
                                     at android.app.ActivityThread.-wrap11(ActivityThread.java)
                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
                                     at android.os.Handler.dispatchMessage(Handler.java:102)
                                     at android.os.Looper.loop(Looper.java:148)
                                     at android.app.ActivityThread.main(ActivityThread.java:5417)
                                     at java.lang.reflect.Method.invoke(Native Method)
                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
                                  Caused by: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class <unknown>
                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
                                     at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:393)
                                     at android.app.Activity.setContentView(Activity.java:2166)
                                     at abcdef.SplashScreen.onCreate(SplashScreen.java:18)
                                     at android.app.Activity.performCreate(Activity.java:6237)
                                     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
                                     at android.app.ActivityThread.-wrap11(ActivityThread.java) 
                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
                                     at android.os.Handler.dispatchMessage(Handler.java:102) 
                                     at android.os.Looper.loop(Looper.java:148) 
                                     at android.app.ActivityThread.main(ActivityThread.java:5417) 
                                     at java.lang.reflect.Method.invoke(Native Method) 
                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
                                  Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
                                     at android.view.LayoutInflater.createView(LayoutInflater.java:645)
                                     at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58)
                                     at android.view.LayoutInflater.onCreateView(LayoutInflater.java:694)
                                     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:762)
                                     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
                                     at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:393) 
                                     at android.app.Activity.setContentView(Activity.java:2166) 
                                     at abcdef.SplashScreen.onCreate(SplashScreen.java:18) 
                                     at android.app.Activity.performCreate(Activity.java:6237) 
                                     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) 
                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) 
                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
                                     at android.app.ActivityThread.-wrap11(ActivityThread.java) 
                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
                                     at android.os.Handler.dispatchMessage(Handler.java:102) 
                                     at android.os.Looper.loop(Looper.java:148) 
                                     at android.app.ActivityThread.main(ActivityThread.java:5417) 
                                     at java.lang.reflect.Method.invoke(Native Method) 
                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
                                  Caused by: java.lang.reflect.InvocationTargetException
                                     at java.lang.reflect.Constructor.newInstance(Native Method)
                                     at android.view.LayoutInflater.createView(LayoutInflater.java:619)
                                     at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58) 
                                     at android.view.LayoutInflater.onCreateView(LayoutInflater.java:694) 
                                     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:762) 
                                     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) 
                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 
                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
                                     at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:393) 
                                     at android.app.Activity.setContentView(Activity.java:2166) 
                                     at abcdef.SplashScreen.onCreate(SplashScreen.java:18) 
                                     at android.app.Activity.performCreate(Activity.java:6237) 
                                     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) 
                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) 
                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
                                     at android.app.ActivityThread.-wrap11(ActivityThread.java) 
                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
                                     at android.os.Handler.dispatchMessage(Handler.java:102) 
                                     at android.os.Looper.loop(Looper.java:148) 
                                     at android.app.ActivityThread.main(ActivityThread.java:5417) 
                                     at java.lang.reflect.Method.invoke(Native Method) 
                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
                                  Caused by: java.lang.OutOfMemoryError: Failed to allocate a 74649612 byte allocation with 1130356 free bytes and 62MB until OOM
                                     at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
                                     at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
                                     at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:609)
                                     at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:444)
                                     at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:1080)
                                     at android.content.res.Resources.loadDrawableForCookie(Resources.java:2635)
                                     at android.content.res.Resources.loadDrawable(Resources.java:2540)
                                     at android.content.res.TypedArray.getDrawable(TypedArray.java:870)
                                     at android.view.View.<init>(View.java:3948)
                                     at android.view.ViewGroup.<init>(ViewGroup.java:573)
                                     at android.widget.LinearLayout.<init>(LinearLayout.java:203)
                                     at android.widget.LinearLayout.<init>(LinearLayout.java:199)
                                     at android.widget.LinearLayout.<init>(LinearLayout.java:195)
                                     at java.lang.reflect.Constructor.newInstance(Native Method) 
                                     at android.view.LayoutInflater.createView(LayoutInflater.java:619) 
                                     at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58) 
                                     at android.view.LayoutInflater.onCreateView(LayoutInflater.java:694) 
                                     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:762) 
                                     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) 
                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 
                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
                                     at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:393) 
                                     at android.app.Activity.setContentView(Activity.java:2166) 
                                     at abcdef.SplashScreen.onCreate(SplashScreen.java:18) 
                                     at android.app.Activity.performCreate(Activity.java:6237) 
                                     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) 
                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) 
                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
                                     at android.app.ActivityThread.-wrap11(ActivityThread.java) 
                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
                                     at android.os.Handler.dispatchMessage(Handler.java:102) 
                                     at android.os.Looper.loop(Looper.java:148) 
                                     at android.app.ActivityThread.main(ActivityThread.java:5417) 
                                     at java.lang.reflect.Method.invoke(Native Method) 
                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 

我在模拟器上进行测试。

修改 在我的启动画面中,我使用两个图像,一个作为我的LinearLayout的背景:

image 1 details

并在其上面放置一个ImageView:

image 1 details

当安装在设备上时,

74,649,612个字节符合我的整个应用程序的大小。还是不知道问题出在哪里?如上所述,在所有其他Android版本上,它运行良好,没有崩溃。

2 个答案:

答案 0 :(得分:3)

  

对于Android M的应用程序中是否存在OpenSSL / BoringSSL缺陷?

没有。您有LinearLayout的背景,解码时为74,649,612字节。你不会有记忆。这相当于8640 x 8640图像,比任何Android设备屏幕 大。<​​/ p>

找出LinearLayout这是什么,并使用更多更小的背景图片。

答案 1 :(得分:0)

要帮助调试,请将setDefaultUncaughtExceptionHandler()添加到启动活动中,以获取有关布局缓冲区阻塞的更多详细信息。并在Activity&#39; onCreate()中调用setDefaultUncaughtExceptionHandler()。

    private static void setDefaultUncaughtExceptionHandler() {
        Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {

        @Override
        public void uncaughtException(Thread t, Throwable e) {
            Log.e(this.getClass().getSimpleName(), "Thread and exception details:",
                    t.getName(), e);
            e.printStackTrace();
        }
    });
}