Es begann erst kürzlich, nachdem ich einige Elemente in meinem Layout verschoben habe. Ich kann den XML-Code auch teilen, wenn Sie denken, dass das helfen würde, das Problem zu lösen.Was in meiner Aktivität verursacht diese Android.Views.InflateException?
Hier ist die Aktivität, die die Ausnahme verursacht:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:p1="http://schemas.android.com/apk/res/android"
p1:layout_width="match_parent"
p1:layout_height="match_parent"
p1:id="@+id/relativeLayout1"
p1:background="@drawable/pickcitybackground">
<ImageView
p1:src="@drawable/pick"
p1:layout_width="60dp"
p1:layout_height="60dp"
p1:id="@+id/pick"
p1:layout_marginLeft="50dp"
p1:layout_marginTop="90dp" />
<ImageButton
p1:src="@drawable/austinbutton"
p1:layout_width="60dp"
p1:layout_height="60dp"
p1:id="@+id/austinButton"
p1:background="#02ffffff"
p1:scaleType="centerCrop"
p1:layout_marginTop="90dp"
p1:layout_marginLeft="210dp" />
<ImageButton
p1:src="@drawable/nashvillebutton"
p1:layout_width="60dp"
p1:layout_height="60dp"
p1:id="@+id/nashvilleButton"
p1:scaleType="centerCrop"
p1:background="#02ffffff"
p1:layout_marginLeft="50dp"
p1:layout_marginTop="265dp" />
<ImageButton
p1:src="@drawable/newyorkbutton"
p1:layout_width="60dp"
p1:layout_height="60dp"
p1:id="@+id/newyorkButton"
p1:scaleType="centerCrop"
p1:background="#02ffffff"
p1:layout_marginTop="265dp"
p1:layout_marginLeft="210dp" />
<ImageButton
p1:src="@drawable/sanfranbutton"
p1:layout_width="60dp"
p1:layout_height="60dp"
p1:id="@+id/sanfranButton"
p1:scaleType="centerCrop"
p1:background="#02ffffff"
p1:layout_marginTop="435dp"
p1:layout_marginLeft="50dp" />
<ImageButton
p1:src="@drawable/seattlebutton"
p1:layout_width="60dp"
p1:layout_height="60dp"
p1:id="@+id/seattleButton"
p1:layout_marginLeft="210dp"
p1:background="#02ffffff"
p1:scaleType="centerCrop"
p1:layout_marginTop="435dp" />
Der Stack-Trace:
Android.Views.InflateException: Binary XML file line #1: Error inflating class android.widget.ImageButton ---> Java.Lang.Reflect.InvocationTargetException: ---> Java.Lang.OutOfMemoryError: Failed to allocate a 182250012 byte allocation with 4194304 free bytes and 74MB until OOM
at java.lang.OutOfMemoryError: Failed to allocate a 182250012 byte allocation with 4194304 free bytes and 74MB until OOM
at at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
at at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:609)
at at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:444)
at at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:988)
at at android.content.res.Resources.loadDrawableForCookie(Resources.java:2474)
at at android.content.res.Resources.loadDrawable(Resources.java:2381)
at at android.content.res.TypedArray.getDrawable(TypedArray.java:749)
at at android.widget.ImageView.<init>(ImageView.java:146)
at at android.widget.ImageButton.<init>(ImageButton.java:86)
at at android.widget.ImageButton.<init>(ImageButton.java:82)
at at android.widget.ImageButton.<init>(ImageButton.java:78)
at at java.lang.reflect.Constructor.newInstance(Native Method)
at at android.view.LayoutInflater.createView(LayoutInflater.java:607)
at at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
at at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
at at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
at at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:378)
at at android.app.Activity.setContentView(Activity.java:2145)
at at md54421ba596fa8cc5324701d9bb904102d.pickCityPage.n_onCreate(Native Method)
at at md54421ba596fa8cc5324701d9bb904102d.pickCityPage.onCreate(pickCityPage.java:29)
at at android.app.Activity.performCreate(Activity.java:5990)
at at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2303)
at at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2415)
at at android.app.ActivityThread.access$900(ActivityThread.java:152)
at at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1328)
at at android.os.Handler.dispatchMessage(Handler.java:102)
at at android.os.Looper.loop(Looper.java:135)
at at android.app.ActivityThread.main(ActivityThread.java:5301)
at at java.lang.reflect.Method.invoke(Native Method)
at at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:723)
at at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:613)
--- End of inner exception stack trace ---
at java.lang.reflect.InvocationTargetException
at at java.lang.reflect.Constructor.newInstance(Native Method)
at at android.view.LayoutInflater.createView(LayoutInflater.java:607)
at at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
at at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
at at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
at at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:378)
at at android.app.Activity.setContentView(Activity.java:2145)
at at md54421ba596fa8cc5324701d9bb904102d.pickCityPage.n_onCreate(Native Method)
at at md54421ba596fa8cc5324701d9bb904102d.pickCityPage.onCreate(pickCityPage.java:29)
at at android.app.Activity.performCreate(Activity.java:5990)
at at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2303)
at at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2415)
at at android.app.ActivityThread.access$900(ActivityThread.java:152)
at at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1328)
at at android.os.Handler.dispatchMessage(Handler.java:102)
at at android.os.Looper.loop(Looper.java:135)
at at android.app.ActivityThread.main(ActivityThread.java:5301)
at at java.lang.reflect.Method.invoke(Native Method)
at at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:723)
at at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:613)
at Caused by: java.lang.OutOfMemoryError: Failed to allocate a 182250012 byte allocation with 4194304 free bytes and 74MB until OOM
at at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
at at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:609)
at at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:444)
at at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:988)
at at android.content.res.Resources.loadDrawableForCookie(Resources.java:2474)
at at android.content.res.Resources.loadDrawable(Resources.java:2381)
at at android.content.res.TypedArray.getDrawable(TypedArray.java:749)
at at android.widget.ImageView.<init>(ImageView.java:146)
at at android.widget.ImageButton.<init>(ImageButton.java:86)
at at android.widget.ImageButton.<init>(ImageButton.java:82)
at at android.widget.ImageButton.<init>(ImageButton.java:78)
at ... 25 more
--- End of inner exception stack trace ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [0x0000c] in /Users/builder/data/lanes/3819/96c7ba6c/source/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143
at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x000a7] in /Users/builder/data/lanes/3819/96c7ba6c/source/Java.Interop/src/Java.Interop/Java.Interop/JniEnvironment.g.cs:12083
at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00068] in /Users/builder/data/lanes/3819/96c7ba6c/source/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods_Invoke.cs:31
at Android.App.Activity.SetContentView (System.Int32 layoutResID) [0x00017] in /Users/builder/data/lanes/3819/96c7ba6c/source/monodroid/src/Mono.Android/platforms/android-24/src/generated/Android.App.Activity.cs:5253
at Quickies.Android.pickCityPage.OnCreate (Android.OS.Bundle bundle) [0x0000e] in /Users/michaelsloan/Desktop/Quickies/Android/Quickies/pickCityPage.cs:28
at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_savedInstanceState) [0x00011] in /Users/builder/data/lanes/3819/96c7ba6c/source/monodroid/src/Mono.Android/platforms/android-24/src/generated/Android.App.Activity.cs:2550
at at (wrapper dynamic-method) System.Object:e8fa207e-6c2f-4c69-899e-9bfde46df162 (intptr,intptr,intptr)
at android.view.InflateException: Binary XML file line #1: Error inflating class android.widget.ImageButton
at at android.view.LayoutInflater.createView(LayoutInflater.java:633)
at at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
at at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
at at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
at at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:378)
at at android.app.Activity.setContentView(Activity.java:2145)
at at md54421ba596fa8cc5324701d9bb904102d.pickCityPage.n_onCreate(Native Method)
at at md54421ba596fa8cc5324701d9bb904102d.pickCityPage.onCreate(pickCityPage.java:29)
at at android.app.Activity.performCreate(Activity.java:5990)
at at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2303)
at at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2415)
at at android.app.ActivityThread.access$900(ActivityThread.java:152)
at at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1328)
at at android.os.Handler.dispatchMessage(Handler.java:102)
at at android.os.Looper.loop(Looper.java:135)
at at android.app.ActivityThread.main(ActivityThread.java:5301)
at at java.lang.reflect.Method.invoke(Native Method)
at at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:723)
at at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:613)
at Caused by: java.lang.reflect.InvocationTargetException
at at java.lang.reflect.Constructor.newInstance(Native Method)
at at android.view.LayoutInflater.createView(LayoutInflater.java:607)
at ... 23 more
at Caused by: java.lang.OutOfMemoryError: Failed to allocate a 182250012 byte allocation with 4194304 free bytes and 74MB until OOM
at at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
at at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:609)
at at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:444)
at at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:988)
at at android.content.res.Resources.loadDrawableForCookie(Resources.java:2474)
at at android.content.res.Resources.loadDrawable(Resources.java:2381)
at at android.content.res.TypedArray.getDrawable(TypedArray.java:749)
at at android.widget.ImageView.<init>(ImageView.java:146)
at at android.widget.ImageButton.<init>(ImageButton.java:86)
at at android.widget.ImageButton.<init>(ImageButton.java:82)
at at android.widget.ImageButton.<init>(ImageButton.java:78)
at ... 25 more
Es ist zu Image id bezogen. – AndroidHacker
post you Layout xml –
Ich habe das XML-Layout veröffentlicht. Irgendwelche Ideen? Ich würde eine Richtung lieben! Ich lese gerade, wie [große Bitmaps effizient zu laden, damit ich diese Ausnahme nicht bekomme] (https://developer.xamarin.com/recipes/android/resources/general/load_large_bitmaps_efficiently/) @MarcoPierucci –