Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rendering issue using Android Studio 0.4.0

I recently decided to try Android Studio after being a while on Eclipse. My main activity xml rendered okay on Eclipse but Studio seems to have a problem with it. It reports this on the Preview window: Rendering Problems java.lang.StackOverflowError Copy stack to clipboard.

Part of the contents (full is > 70K characters) of the clipboard is:

java.lang.StackOverflowError
    at com.android.tools.idea.rendering.ProjectCallback.loadView(ProjectCallback.java:153)
    at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:207)
    at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:135)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:755)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:727)
    at android.view.LayoutInflater_Delegate.parseInclude(LayoutInflater_Delegate.java:154)
    at android.view.LayoutInflater.parseInclude(LayoutInflater.java:782)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:745)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:727)
    at android.view.LayoutInflater_Delegate.parseInclude(LayoutInflater_Delegate.java:154)
    at android.view.LayoutInflater.parseInclude(LayoutInflater.java:782)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:745)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:727)
    at android.view.LayoutInflater_Delegate.parseInclude(LayoutInflater_Delegate.java:154)
    at android.view.LayoutInflater.parseInclude(LayoutInflater.java:782)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:745)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:727)
    at android.view.LayoutInflater_Delegate.parseInclude(LayoutInflater_Delegate.java:154)
    at android.view.LayoutInflater.parseInclude(LayoutInflater.java:782)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:745)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:727)
    at android.view.LayoutInflater_Delegate.parseInclude(LayoutInflater_Delegate.java:154)
    at android.view.LayoutInflater.parseInclude(LayoutInflater.java:782)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:745)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:727)
    at android.view.LayoutInflater_Delegate.parseInclude(LayoutInflater_Delegate.java:154)
    at android.view.LayoutInflater.parseInclude(LayoutInflater.java:782)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:745)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:727)
    at android.view.LayoutInflater_Delegate.parseInclude(LayoutInflater_Delegate.java:154)
    at android.view.LayoutInflater.parseInclude(LayoutInflater.java:782)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:745)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:727)
    at android.view.LayoutInflater_Delegate.parseInclude(LayoutInflater_Delegate.java:154)
    at android.view.LayoutInflater.parseInclude(LayoutInflater.java:782)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:745)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:727)
    at android.view.LayoutInflater_Delegate.parseInclude(LayoutInflater_Delegate.java:154)
    at android.view.LayoutInflater.parseInclude(LayoutInflater.java:782)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:745)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:727)
    at android.view.LayoutInflater_Delegate.parseInclude(LayoutInflater_Delegate.java:154)
    at android.view.LayoutInflater.parseInclude(LayoutInflater.java:782)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:745)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:727)
    at android.view.LayoutInflater_Delegate.parseInclude(LayoutInflater_Delegate.java:154)

The actual xml code is:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity" >

<TextView
    android:id="@+id/currentPosition"
    style="@style/ScreenFont_Normal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:background="#F7F7E6"
    android:textColor="#8B8B8B"
    android:text="@string/curr_loca" />

<fragment 
    android:id="@+id/map"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@+id/currentPosition"
    class="com.google.android.gms.maps.SupportMapFragment"
    tools:layout="@layout/activity_main"/>

<ProgressBar
    android:id="@+id/progressBar1"
    style="?android:attr/progressBarStyleLarge"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true" />

</RelativeLayout> 

Although this does not affect the build and creation of the .apk file I would still like to take advantage of the cool graphical UI editing features of Studio.

Any help would be greatly appreciated

Cheers

like image 819
Carlos Taylor Avatar asked Dec 28 '13 04:12

Carlos Taylor


1 Answers

Remove the following line from the XML inside your fragment:

tools:layout="@layout/activity_main"/>

Reason: In Android Studio, you're presented with an option to edit separate layouts when working with an XML document containing a fragment. Upon selecting the option to edit the parent layout, this line above is inserted into the code. Cheers

like image 132
lukeswitz Avatar answered Nov 04 '22 23:11

lukeswitz