{"id":2253,"date":"2022-08-30T15:23:19","date_gmt":"2022-08-30T15:23:19","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/01\/05\/gridlayout-giving-errors-crashing-app-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:23:19","modified_gmt":"2022-08-30T15:23:19","slug":"gridlayout-giving-errors-crashing-app-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/gridlayout-giving-errors-crashing-app-collection-of-common-programming-errors\/","title":{"rendered":"GridLayout giving errors, crashing app-Collection of common programming errors"},"content":{"rendered":"<p>I&#8217;m pretty new to layouts, but I was able to successfully make a pretty nice looking layout (for a tablet). In Eclipse, it works great. I made it all with the &#8216;target&#8217; on Android 4.0 (ICS), but obviously my tablet only runs 3.0 (Honeycomb). When I realised the error, I changed the viewer\/editing config to 3.2, but Eclipse won&#8217;t even display the graphic of the layout anymore, it simply spits out:<\/p>\n<pre><code>com.android.layoutlib.bridge.MockView cannot be cast to android.view.ViewGroup\n    Exception details are logged in Window &gt; Show View &gt; Error Log\n    The following classes could not be found:\n    - GridLayout (Change to android.widget.GridLayout, Fix Build Path, Edit XML)\n<\/code><\/pre>\n<p>The error log pops out:<\/p>\n<pre><code>java.lang.ClassCastException: com.android.layoutlib.bridge.MockView cannot be cast to android.view.ViewGroup\nat android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:84)\nat android.view.LayoutInflater.rInflate(LayoutInflater.java:702)\nat android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:86)\nat android.view.LayoutInflater.rInflate(LayoutInflater.java:702)\nat android.view.LayoutInflater.inflate(LayoutInflater.java:479)\nat android.view.LayoutInflater.inflate(LayoutInflater.java:367)\nat com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:324)\nat com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:321)\nat com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:325)\nat com.android.ide.eclipse.adt.internal.editors.layout.gle2.RenderService.createRenderSession(RenderService.java:372)\nat com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.renderWithBridge(GraphicalEditorPart.java:1317)\nat com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.recomputeLayout(GraphicalEditorPart.java:1071)\nat com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart$ConfigListener.onConfigurationChange(GraphicalEditorPart.java:493)\nat com.android.ide.eclipse.adt.internal.editors.layout.configuration.ConfigurationComposite.onRenderingTargetChange(ConfigurationComposite.java:2192)\nat com.android.ide.eclipse.adt.internal.editors.layout.configuration.ConfigurationComposite.access$4(ConfigurationComposite.java:2157)\nat com.android.ide.eclipse.adt.internal.editors.layout.configuration.ConfigurationComposite$2.widgetSelected(ConfigurationComposite.java:441)\nat org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:234)\nat org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)\nat org.eclipse.swt.widgets.Display.sendEvent(Display.java:3783)\nat org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1375)\nat org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1398)\nat org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1383)\nat org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1195)\nat org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3629)\nat org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3284)\nat org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2640)\nat org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604)\nat org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2438)\nat org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671)\nat org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)\nat org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:664)\nat org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)\nat org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)\nat org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)\nat org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)\nat org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)\nat org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)\nat org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)\nat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\nat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)\nat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)\nat java.lang.reflect.Method.invoke(Method.java:597)\nat org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:620)\nat org.eclipse.equinox.launcher.Main.basicRun(Main.java:575)\nat org.eclipse.equinox.launcher.Main.run(Main.java:1408)\n<\/code><\/pre>\n<p>And here is my layout:<\/p>\n<pre><code>\n\n\n\n\n    \n\n    \n\n        \n\n            \n\n            \n\n            \n\n            \n\n            \n\n            \n\n            \n\n            \n\n            \n\n            \n\n            \n        \n\n        \n\n            \n\n            \n\n            \n\n            \n\n            \n\n        \n\n        \n\n            \n\n                \n\n                \n            \n        \n    \n\n\n\n\n<\/code><\/pre>\n<p>Ultimately, I&#8217;m able to install the app on my tablet, but it just crashes right away with this from LogCat:<\/p>\n<pre><code>    10-29 23:44:05.180: E\/AndroidRuntime(14135): FATAL EXCEPTION: main\n    10-29 23:44:05.180: E\/AndroidRuntime(14135): java.lang.RuntimeException: Unable to start activity ComponentInfo{ca.ajwest.irishpoker\/ca.ajwest.irishpoker.IrishPokerActivity}: java.lang.UnsupportedOperationException: addView(View, LayoutParams) is not supported in AdapterView\n    10-29 23:44:05.180: E\/AndroidRuntime(14135):    at      android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1741)\n    10-29 23:44:05.180: E\/AndroidRuntime(14135):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1757)\n    10-29 23:44:05.180: E\/AndroidRuntime(14135):    at android.app.ActivityThread.access$1500(ActivityThread.java:123)\n    10-29 23:44:05.180: E\/AndroidRuntime(14135):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:998)\n    10-29 23:44:05.180: E\/AndroidRuntime(14135):    at android.os.Handler.dispatchMessage(Handler.java:99)\n    10-29 23:44:05.180: E\/AndroidRuntime(14135):    at android.os.Looper.loop(Looper.java:126)\n    10-29 23:44:05.180: E\/AndroidRuntime(14135):    at android.app.ActivityThread.main(ActivityThread.java:4002)\n    10-29 23:44:05.180: E\/AndroidRuntime(14135):    at java.lang.reflect.Method.invokeNative(Native Method)\n    10-29 23:44:05.180: E\/AndroidRuntime(14135):    at java.lang.reflect.Method.invoke(Method.java:491)\n    10-29 23:44:05.180: E\/AndroidRuntime(14135):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:844)\n    10-29 23:44:05.180: E\/AndroidRuntime(14135):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)\n    10-29 23:44:05.180: E\/AndroidRuntime(14135):    at dalvik.system.NativeStart.main(Native Method)\n    10-29 23:44:05.180: E\/AndroidRuntime(14135): Caused by: java.lang.UnsupportedOperationException: addView(View, LayoutParams) is not supported in AdapterView\n    10-29 23:44:05.180: E\/AndroidRuntime(14135):    at android.widget.AdapterView.addView(AdapterView.java:459)\n    10-29 23:44:05.180: E\/AndroidRuntime(14135):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:728)\n    10-29 23:44:05.180: E\/AndroidRuntime(14135):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:727)\n    10-29 23:44:05.180: E\/AndroidRuntime(14135):    at android.view.LayoutInflater.inflate(LayoutInflater.java:479)\n    10-29 23:44:05.180: E\/AndroidRuntime(14135):    at android.view.LayoutInflater.inflate(LayoutInflater.java:391)\n    10-29 23:44:05.180: E\/AndroidRuntime(14135):    at android.view.LayoutInflater.inflate(LayoutInflater.java:347)\n    10-29 23:44:05.180: E\/AndroidRuntime(14135):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:247)\n    10-29 23:44:05.180: E\/AndroidRuntime(14135):    at android.app.Activity.setContentView(Activity.java:1771)\n    10-29 23:44:05.180: E\/AndroidRuntime(14135):    at ca.ajwest.irishpoker.IrishPokerActivity.onCreate(IrishPokerActivity.java:30)\n    10-29 23:44:05.180: E\/AndroidRuntime(14135):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)\n    10-29 23:44:05.180: E\/AndroidRuntime(14135):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1705)\n    10-29 23:44:05.180: E\/AndroidRuntime(14135):    ... 11 more\n<\/code><\/pre>\n<p>Will re-making the whole layout with 2.3 selected fix this problem? That&#8217;s sooo sucky&#8230;<\/p>\n<p id=\"rop\"><small>Originally posted 2014-01-05 09:32:52. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I&#8217;m pretty new to layouts, but I was able to successfully make a pretty nice looking layout (for a tablet). In Eclipse, it works great. I made it all with the &#8216;target&#8217; on Android 4.0 (ICS), but obviously my tablet only runs 3.0 (Honeycomb). When I realised the error, I changed the viewer\/editing config to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2253","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2253","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=2253"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2253\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=2253"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=2253"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=2253"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}