1

i have problem in my android project when i trying to add calendar view or date picker there is Rendering problem message appear

Message: " Rendering problems Exception raised during rendering : Binary XML file line #-1: Error inflating class unknown> "

and this is the message details


java.lang.NoSuchFieldError: this$0
at android.view.ViewRootImpl$RunQueue.postDelayed(ViewRootImpl.java:6872)
at android.view.View.postDelayed(View.java:13008)
at android.widget.CalendarViewLegacyDelegate$ScrollStateRunnable.doScrollStateChange(CalendarViewLegacyDelegate.java:956)
at android.widget.CalendarViewLegacyDelegate.onScrollStateChanged(CalendarViewLegacyDelegate.java:829)
at android.widget.CalendarViewLegacyDelegate.goTo(CalendarViewLegacyDelegate.java:816)
at android.widget.CalendarViewLegacyDelegate.<init>(CalendarViewLegacyDelegate.java:334)
at android.widget.CalendarView.<init>(CalendarView.java:105)
at android.widget.CalendarView.<init>(CalendarView.java:92)
at android.widget.CalendarView.<init>(CalendarView.java:88)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at android.view.LayoutInflater.createView(LayoutInflater.java:619)
at android.view.BridgeInflater.onCreateView(BridgeInflater.java:107)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:694)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:762)
at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:149)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:835)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:811)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:838)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:811)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:838)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:811)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:838)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:811)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
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:229)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:426)
at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:350)
at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:520)
at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:508)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:967)
at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:508)
at com.android.tools.idea.rendering.RenderTask.access$600(RenderTask.java:75)
at com.android.tools.idea.rendering.RenderTask$3.call(RenderTask.java:620)
at com.android.tools.idea.rendering.RenderTask$3.call(RenderTask.java:617)
at com.android.tools.idea.rendering.RenderService.runRenderAction(RenderService.java:371)
at com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:617)
at com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:639)
at com.intellij.android.designer.designSurface.AndroidDesignerEditorPanel$7.run(AndroidDesignerEditorPanel.java:519)
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:337)
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:327)
at com.intellij.util.ui.update.MergingUpdateQueue$3.run(MergingUpdateQueue.java:271)
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:286)
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:244)
at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:234)
at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
at com.intellij.util.Alarm$Request$1.run(Alarm.java:352)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:695)

and this is my layout xml file

<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="com.laguses.callsrecorder.callsrecorderapp.Records">


<LinearLayout
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@color/backgroundcolor"
        android:paddingTop="20dp"
        android:paddingBottom="20dp"
        android:paddingLeft="15dp"
        android:paddingRight="15dp"
        android:gravity="center">

        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/imageView26"
                android:src="@mipmap/records_showfilter_icn" />
        </LinearLayout>

        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/imageView27"
                android:src="@mipmap/records_hidefilter_icn" />
        </LinearLayout>

        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="right">

            <LinearLayout
                android:orientation="horizontal"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center">

                <EditText
                    android:layout_width="112dp"
                    android:layout_height="wrap_content"
                    android:id="@+id/editText"
                    android:singleLine="true"
                    android:textColor="#ffffff"
                    android:background="@drawable/search_field_borderstyle" />

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/imageView25"
                    android:src="@mipmap/records_search_icn"
                    android:layout_marginLeft="10dp" />
            </LinearLayout>
        </LinearLayout>

    </LinearLayout>

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:padding="20dp"
        android:background="@color/backgroundcolor">

        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@drawable/filtergroupshape">

            <LinearLayout
                android:orientation="vertical"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content">

                <CheckBox
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Incoming Calls"
                    android:id="@+id/checkBox"
                    android:checked="false" />

                <CheckBox
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Outgoing Calls"
                    android:id="@+id/checkBox2"
                    android:checked="false" />

                <CheckBox
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Missed Calls"
                    android:id="@+id/checkBox3"
                    android:checked="false" />

                <CheckBox
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Fails Calls"
                    android:id="@+id/checkBox4"
                    android:checked="false" />

                <CheckBox
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Favorite Calls"
                    android:id="@+id/checkBox5"
                    android:checked="false" />
            </LinearLayout>

            <CalendarView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:id="@+id/calendarView"
                android:layout_gravity="center_vertical" />

        </LinearLayout>
    </LinearLayout>

</LinearLayout>

finally i noticed that error appear only when i'm trying to add calendar view or date picker

O.AbedElBaset
  • 1,710
  • 2
  • 13
  • 11
  • **0** - You're missing the xml declaration. **1** - Where is this namespace defined `com.laguses.callsrecorder.callsrecorderapp.Records` in your xml? **2** - You shouldn't use the `mipmap` folders for your resources, other than the **app icon**. Use the `drawable` folders, instead. – Phantômaxx May 07 '16 at 14:45
  • 0- i added the xml declaration but still same error 1- please explain more , Records is an activity and the xml i post its layout xml file 3- i use mipmap because i using mdpi hdpi xhdpi xxhdpi xxxhdpi folder in mipmap because i cant find "mdpi hdpi xhdpi xxhdpi xxxhdpi" folder in drawable – O.AbedElBaset May 07 '16 at 15:45
  • **1** - you MUST add a namespace for every "foreign" object. This has to be done in your xml layout. **2** - Create the `drawables` folders you don't `"find"` and please stop using `mipmaps`, as it is **inappropriate**. – Phantômaxx May 07 '16 at 15:51
  • 1- can you please show me how to add namespace for foreign object in my xml layout 2- ok i will create folders in drawable but why i shouldn't use mipmap is it risky ? thanks for your helping – O.AbedElBaset May 07 '16 at 17:03
  • **1** - add an `xmlns` element to your RelativeLayout declaration, like you do for the other namespaces (`android` and `tools`). **2** - http://stackoverflow.com/questions/28065267/mipmap-vs-drawable-folders – Phantômaxx May 07 '16 at 17:24
  • error still not fixed :S – O.AbedElBaset May 07 '16 at 19:45
  • Did you try "Invalidate caches / Restart..." in android studio? – Tushar Monirul Jul 26 '16 at 10:58

2 Answers2

0

You are missing the character encoding for XML files, add line before declaring the elements

 <?xml version="1.0" encoding="UTF-8"?>
 <RelativeLayout
 //Your XML code here
Veeresh Charantimath
  • 4,641
  • 5
  • 27
  • 36
  • 1
    More info on this : http://stackoverflow.com/questions/13743250/meaning-of-xml-version-1-0-encoding-utf-8 – Veeresh Charantimath May 07 '16 at 14:48
  • 3
    Yes, the encoding is missing - but in what way does this relate to the question? In my case, this does not remedy the error at all! – Zordid Aug 25 '16 at 09:04
0

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
    android:orientation="vertical"
    tools:context="com.example.android.justjava.MainActivity">

    <TextView
        android:id="@+id/cobertura"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="16dp"
        android:text="Coberturas"
        android:textAllCaps="true"
        android:textSize="16sp" />

    <CheckBox
        android:id="@+id/crema_checkbox"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:checked="false"
        android:text="Crema" />

    <TextView
        android:id="@+id/cantidad"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="16dp"
        android:text="¿Cuantas tazas de café desea?"
        android:textAllCaps="true"
        android:textSize="16sp" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:weightSum="1">

        <Button
            android:layout_width="48dp"
            android:layout_height="48dp"
            android:layout_marginLeft="16dp"
            android:onClick="decrecer"
            android:text="-" />

        <TextView
            android:id="@+id/cantidad_text_view"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="16dp"
            android:layout_weight="0.13"
            android:text="0"
            android:textColor="#000000"
            android:textSize="16dp" />

        <Button
            android:id="@+id/button"
            android:layout_width="48dp"
            android:layout_height="48dp"
            android:layout_marginLeft="16dp"
            android:onClick="incrementar"
            android:text="+" />

        <Button
            android:layout_width="wrap_content"
            android:layout_height="48dp"
            android:layout_marginLeft="32dp"
            android:onClick="submitOrder"
            android:text="ORDEN" />

    </LinearLayout>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="16dp"
        android:text="Orden de Pedido"
        android:textAllCaps="true"
        android:textSize="16sp" />

    <TextView
        android:id="@+id/orden_de_pedido_text_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="16dp"
        android:text="BsF 0"
        android:textColor="#000000"
        android:textSize="16dp" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="15dp"
        android:onClick="reiniciar"
        android:text="reinicio" />

</LinearLayout>
  • 2
    It is always preferred to include what changes you made and how it fixed the issue so that the OP and future visitors may get the clearer picture. – Shaishav Aug 21 '16 at 05:48