我对编程还很陌生。出现致命异常错误。二进制 XML 文件行 #0
I am fairly new to programming. Having FATAL EXCEPTION error. Binary XML file line #0
FATAL EXCEPTION: main
Process: com.onyebuchboss.bossweatherbitcoinapp, PID: 11494
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.onyebuchboss.bossweatherbitcoinapp/com.onyebuchboss.bossweatherbitcoinapp.OptionActivity}: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class <unknown>
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2743)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2808)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1544)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6293)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1094)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:955)
Caused by: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class <unknown>
Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class <unknown>
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
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:717)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:785)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.inflate(LayoutInflater.java:495)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.onyebuchboss.bossweatherbitcoinapp.OptionActivity.onCreate(OptionActivity.java:23)
at android.app.Activity.performCreate(Activity.java:6702)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2696)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2808)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1544)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6293)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1094)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:955)
Caused by: java.lang.OutOfMemoryError: Failed to allocate a 493807116 byte allocation with 4194304 free bytes and 155MB until OOM
at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:655)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:483)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:1160)
at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:841)
at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:641)
at android.content.res.Resources.loadDrawable(Resources.java:976)
at android.content.res.TypedArray.getDrawable(TypedArray.java:930)
at android.view.View.<init>(View.java:4348)
at android.view.ViewGroup.<init>(ViewGroup.java:616)
at android.widget.RelativeLayout.<init>(RelativeLayout.java:268)
at android.widget.RelativeLayout.<init>(RelativeLayout.java:264)
at android.widget.RelativeLayout.<init>(RelativeLayout.java:260)
此错误的有用部分是 java.lang.OutOfMemoryError
部分。从那里往下看,您可以看到与解码位图相关的堆栈调用。这就是说您有一个大位图,在加载时导致内存不足错误。
检查 xml 中的所有 ImageView 并查找大图像。
当您在加载布局时发生崩溃,实际错误通常隐藏在崩溃日志中。
FATAL EXCEPTION: main
Process: com.onyebuchboss.bossweatherbitcoinapp, PID: 11494
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.onyebuchboss.bossweatherbitcoinapp/com.onyebuchboss.bossweatherbitcoinapp.OptionActivity}: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class <unknown>
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2743)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2808)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1544)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6293)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1094)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:955)
Caused by: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class <unknown>
Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class <unknown>
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
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:717)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:785)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.inflate(LayoutInflater.java:495)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.onyebuchboss.bossweatherbitcoinapp.OptionActivity.onCreate(OptionActivity.java:23)
at android.app.Activity.performCreate(Activity.java:6702)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2696)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2808)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1544)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6293)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1094)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:955)
Caused by: java.lang.OutOfMemoryError: Failed to allocate a 493807116 byte allocation with 4194304 free bytes and 155MB until OOM
at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:655)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:483)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:1160)
at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:841)
at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:641)
at android.content.res.Resources.loadDrawable(Resources.java:976)
at android.content.res.TypedArray.getDrawable(TypedArray.java:930)
at android.view.View.<init>(View.java:4348)
at android.view.ViewGroup.<init>(ViewGroup.java:616)
at android.widget.RelativeLayout.<init>(RelativeLayout.java:268)
at android.widget.RelativeLayout.<init>(RelativeLayout.java:264)
at android.widget.RelativeLayout.<init>(RelativeLayout.java:260)
此错误的有用部分是 java.lang.OutOfMemoryError
部分。从那里往下看,您可以看到与解码位图相关的堆栈调用。这就是说您有一个大位图,在加载时导致内存不足错误。
检查 xml 中的所有 ImageView 并查找大图像。
当您在加载布局时发生崩溃,实际错误通常隐藏在崩溃日志中。