androidxmlandroid-studiodesignview

Android - "Exception raised during rendering: Could not initialize class libcore.util.ZoneInfoDB" on preview and design view


I get this render problem when trying to view the preview or design view in some of my my xml layouts:

Exception raised during rendering: Could not initialize class libcore.util.ZoneInfoDB

Here is one of my layouts with the problem:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    android:id="@+id/rl"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <RelativeLayout
        android:id="@+id/rlMeasures"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_marginBottom="5dp"
        android:layout_marginLeft="15dp"
        android:layout_marginRight="15dp"
        android:layout_marginTop="5dp" >

        <TextView
            android:id="@+id/tvBat"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="@string/percentage"
            android:textSize="20sp" />

        <TextView
            android:id="@+id/tvAlarm"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignTop="@+id/tvBat"
            android:layout_toRightOf="@id/tvBat"
            android:layout_toEndOf="@id/tvBat"
            android:gravity="end"
            android:text="@string/blank"
            android:textSize="20sp" />
    </RelativeLayout>

    <RelativeLayout
        android:id="@+id/rlTime"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/rlMeasures"
        android:layout_centerHorizontal="true" >

        <TextView
            android:id="@+id/tvTime"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:text="@string/time"
            android:textSize="80sp" />

        <TextView
            android:id="@+id/tvDate"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/tvTime"
            android:layout_centerHorizontal="true"
            android:gravity="center"
            android:text="@string/date"
            android:textSize="20sp" />

        <TextView
            android:id="@+id/tvAmPm"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignBottom="@+id/tvTime"
            android:layout_marginBottom="15dp"
            android:layout_marginStart="5dp"
            android:layout_marginLeft="5dp"
            android:layout_toRightOf="@id/tvTime"
            android:layout_toEndOf="@id/tvTime"
            android:gravity="center"
            android:text="@string/ampm"
            android:textSize="20sp" />
    </RelativeLayout>

    <AnalogClock
        android:id="@+id/ac"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_above="@+id/rlTime"
        android:layout_below="@+id/adView"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:dial="@drawable/acnbface"
        android:hand_hour="@drawable/achour"
        android:hand_minute="@drawable/acminute" />

    <com.google.android.gms.ads.AdView
        android:id="@+id/adView"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        ads:adSize="BANNER"
        ads:adUnitId="ca-app-pub-6205053969368684/3258044850"
        android:gravity="center" >
    </com.google.android.gms.ads.AdView>

    <RelativeLayout
        android:id="@+id/rlActivity"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_centerVertical="true"
        android:layout_gravity="center_vertical"
        android:background="@drawable/gradientright"
        android:gravity="center_vertical|start" >

        <ScrollView
            android:id="@+id/svActivity"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            tools:ignore="UselessParent" >

            <RelativeLayout
                android:id="@+id/rlActivity2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_vertical" >

                <ImageButton
                    android:id="@+id/ibStopwatch"
                    android:layout_width="80dp"
                    android:layout_height="80dp"
                    android:layout_margin="10dp"
                    android:background="@drawable/stopwatch"
                    android:contentDescription="@string/stopwatch" />

                <ImageButton
                    android:id="@+id/ibFs"
                    android:layout_width="80dp"
                    android:layout_height="80dp"
                    android:layout_below="@id/ibStopwatch"
                    android:layout_margin="10dp"
                    android:background="@drawable/fs"
                    android:contentDescription="@string/fs" />

                <ImageButton
                    android:id="@+id/ibFsn"
                    android:layout_width="80dp"
                    android:layout_height="80dp"
                    android:layout_below="@id/ibFs"
                    android:layout_margin="10dp"
                    android:background="@drawable/fsnm"
                    android:contentDescription="@string/fsn" />
            </RelativeLayout>
        </ScrollView>
    </RelativeLayout>

    <RelativeLayout
        android:id="@+id/rlShort"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true"
        android:layout_gravity="center_vertical"
        android:background="@drawable/gradientleft"
        android:gravity="center_vertical|end" >

        <ScrollView
            android:id="@+id/svShort"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            tools:ignore="UselessParent" >

            <RelativeLayout
                android:id="@+id/rlShort2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_vertical" >

                <ImageButton
                    android:id="@+id/ibMusic"
                    android:layout_width="60dp"
                    android:layout_height="60dp"
                    android:layout_margin="5dp"
                    android:background="@drawable/music"
                    android:contentDescription="@string/music" />

                <ImageButton
                    android:id="@+id/ibYoutube"
                    android:layout_width="60dp"
                    android:layout_height="60dp"
                    android:layout_below="@id/ibMusic"
                    android:layout_margin="5dp"
                    android:background="@drawable/youtube"
                    android:contentDescription="@string/youtube" />

                <ImageButton
                    android:id="@+id/ibKeep"
                    android:layout_width="60dp"
                    android:layout_height="60dp"
                    android:layout_below="@id/ibYoutube"
                    android:layout_margin="5dp"
                    android:background="@drawable/keep"
                    android:contentDescription="@string/keep" />

                <ImageButton
                    android:id="@+id/ibPlay"
                    android:layout_width="60dp"
                    android:layout_height="60dp"
                    android:layout_below="@id/ibKeep"
                    android:layout_margin="5dp"
                    android:background="@drawable/play"
                    android:contentDescription="@string/play" />

                <ImageButton
                    android:id="@+id/ibSearch"
                    android:layout_width="60dp"
                    android:layout_height="60dp"
                    android:layout_below="@id/ibPlay"
                    android:layout_margin="5dp"
                    android:background="@drawable/search"
                    android:contentDescription="@string/search" />

                <ImageButton
                    android:id="@+id/ibBrowser"
                    android:layout_width="60dp"
                    android:layout_height="60dp"
                    android:layout_below="@id/ibSearch"
                    android:layout_margin="5dp"
                    android:background="@drawable/browser"
                    android:contentDescription="@string/browser" />
            </RelativeLayout>
        </ScrollView>
    </RelativeLayout>

</RelativeLayout>

I am getting no errors or warnings from Android Studio and i can debug the application without any issues. Can anyone explain to me the situation? is it something in my code or an Android Studio Bug?

Thanks


Solution

  • This error occurs with the AnalogClock under Android 21. You can try switching (temporarily) to Android L or lower while you work on your layout.

    A report was filed for this issue at http://b.android.com/79160