Mohit
Mohit

Reputation: 1275

"Something Went Wrong" while opening the layout in design mode

I'm very new android development. I'm using Visual Studio 2017 and Xamarin. I'm facing a issue when opening activity_main.axml in the designer. I'm able to debug the app in the emulator this error is only thrown in the design mode.

Error Log:

Indirect rendering enabled Creating LibraryClassLoader in shadow copy path C:\Users\Dell\AppData\Local\Temp\AndroidDesignerJars4571381395840691254 Setting id 2 on newly created ClassLoader

Trying to load class android.support.design.widget.CoordinatorLayout

An exception occured while loading control android.support.design.widget.CoordinatorLayout java.lang.reflect.InvocationTargetException at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at mono.android.SessionProjectCallback.instantiateClass(SessionProjectCallback.java:404) at mono.android.SessionProjectCallback.loadView(SessionProjectCallback.java:204) at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:337) at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:348) at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:248) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730) at android.view.LayoutInflater.inflate(LayoutInflater.java:492) at android.view.LayoutInflater.inflate(LayoutInflater.java:394) at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:325) at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:384) at com.android.tools.idea.layoutlib.LayoutLibrary.createSession(LayoutLibrary.java:270) at mono.android.DesignerSession.load(DesignerSession.java:289) at mono.android.DesignerSession.processMessage(DesignerSession.java:657) at mono.android.MessageListener.executeMessage(MessageListener.java:88) at mono.android.MessageListener$Runner.run(MessageListener.java:44) at java.lang.Thread.run(Thread.java:748) Caused by: java.lang.IllegalArgumentException: You need to use a Theme.AppCompat theme (or descendant) with the design library. at android.support.design.widget.ThemeUtils.checkAppCompatTheme(ThemeUtils.java:33) at android.support.design.widget.CoordinatorLayout.(CoordinatorLayout.java:206) at android.support.design.widget.CoordinatorLayout.(CoordinatorLayout.java:200) ... 20 more

Trying to load class android.support.design.widget.AppBarLayout

An exception occured while loading control android.support.design.widget.AppBarLayout java.lang.reflect.InvocationTargetException at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at mono.android.SessionProjectCallback.instantiateClass(SessionProjectCallback.java:404) at mono.android.SessionProjectCallback.loadView(SessionProjectCallback.java:204) at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:337) at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:348) at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:248) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730) at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:863) at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72) at android.view.LayoutInflater.rInflate(LayoutInflater.java:837) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824) at android.view.LayoutInflater.inflate(LayoutInflater.java:515) at android.view.LayoutInflater.inflate(LayoutInflater.java:394) at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:325) at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:384) at com.android.tools.idea.layoutlib.LayoutLibrary.createSession(LayoutLibrary.java:270) at mono.android.DesignerSession.load(DesignerSession.java:289) at mono.android.DesignerSession.processMessage(DesignerSession.java:657) at mono.android.MessageListener.executeMessage(MessageListener.java:88) at mono.android.MessageListener$Runner.run(MessageListener.java:44) at java.lang.Thread.run(Thread.java:748) Caused by: java.lang.IllegalArgumentException: You need to use a Theme.AppCompat theme (or descendant) with the design library. at android.support.design.widget.ThemeUtils.checkAppCompatTheme(ThemeUtils.java:33) at android.support.design.widget.AppBarLayout.(AppBarLayout.java:158) ... 24 more

Trying to load class android.support.v7.widget.Toolbar

Bridge [resources.resolve.theme] Failed to find style 'toolbarStyle' in current theme Bridge [resources.resolve.theme] Failed to find style 'toolbarStyle' in current theme Bridge [resources.resolve.theme] Failed to find style 'toolbarStyle' in current theme Bridge [resources.format] You must supply a layout_height attribute. Failed to process message Load mono.android.DesignerException: java.lang.NullPointerException at mono.android.DesignerException.fromThrowable(DesignerException.java:46) at mono.android.DesignerSession.checkRenderResultForError(DesignerSession.java:217) at mono.android.DesignerSession.load(DesignerSession.java:296) at mono.android.DesignerSession.processMessage(DesignerSession.java:657) at mono.android.MessageListener.executeMessage(MessageListener.java:88) at mono.android.MessageListener$Runner.run(MessageListener.java:44) at java.lang.Thread.run(Thread.java:748) Caused by: java.lang.NullPointerException

activity_main.axml

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme">
        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:popupTheme="@style/AppTheme.PopupOverlay" />
    </android.support.design.widget.AppBarLayout>
    <include
        layout="@layout/content_main" />
    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_margin="@dimen/fab_margin"
        app:srcCompat="@android:drawable/ic_dialog_email" />
</android.support.design.widget.CoordinatorLayout>

Screenshot

Screenshot of visual studio. As you can see nothing is rendered at all.

Upvotes: 1

Views: 1905

Answers (3)

Gurdeep
Gurdeep

Reputation: 1

I was getting the following error:

Indirect rendering enabled Failed to process message Load

i checked by design and found that i have created a table layout with three rows and three columns. and in third row i have put only one text view.

I have solved this error by putting three different tables. First table contains three columns, second table contains two columns and third table contains two columns.

Upvotes: 0

Ahmad Bazzi
Ahmad Bazzi

Reputation: 113

Well, for me I had the up-to-date version, i.e. I had navigated to "Check for updates" and got the following:

enter image description here All I had to do was hit "Clean", "Rebuild", "Build" as follows enter image description here and I was good to go. Hope this could help someone who runs thru the same error and has the most recent version of Visual Studio.

Upvotes: 0

mohas
mohas

Reputation: 1931

I hope this helps someone like me, after spending hours searching and trying different things, my problem was that I didn't close an XML tag, but VS failed to tell me so instead I saw Indirect rendering enabled and java.lang.ClassCastException

Upvotes: 1

Related Questions