64

image of problem

I tried to include check boxes in the layout and after dragging and dropping I get this error:

exception raised during rendering:Binary XML file line #-1:error inflating class<unknown>.

xml file:

<?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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.nidhigupta.shopping2.MainActivity">

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Hello World!"
    android:id="@+id/textView" />

<CheckBox
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="New CheckBox"
    android:id="@+id/checkBox"
    android:layout_below="@+id/textView"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true" />

</RelativeLayout>

please provide step by step solution.

details link says :

java.lang.NoSuchMethodError: android.graphics.drawable.VectorDrawable_Delegate.nCreateTreeFromCopy(JJ)J
at android.graphics.drawable.VectorDrawable.nCreateTreeFromCopy(VectorDrawable.java)
at android.graphics.drawable.VectorDrawable.access$400(VectorDrawable.java:204)
at android.graphics.drawable.VectorDrawable$VectorDrawableState.createNativeTreeFromCopy(VectorDrawable.java:837)
at android.graphics.drawable.VectorDrawable$VectorDrawableState.<init>(VectorDrawable.java:812)
at android.graphics.drawable.VectorDrawable.mutate(VectorDrawable.java:268)
at android.graphics.drawable.DrawableContainer$DrawableContainerState.addChild(DrawableContainer.java:817)
at android.graphics.drawable.StateListDrawable$StateListState.addStateSet(StateListDrawable.java:329)
at android.graphics.drawable.AnimatedStateListDrawable$AnimatedStateListState.addStateSet(AnimatedStateListDrawable.java:602)
at android.graphics.drawable.AnimatedStateListDrawable.parseItem(AnimatedStateListDrawable.java:525)
at android.graphics.drawable.AnimatedStateListDrawable.inflateChildElements(AnimatedStateListDrawable.java:453)
at android.graphics.drawable.AnimatedStateListDrawable.inflate(AnimatedStateListDrawable.java:385)
at android.graphics.drawable.DrawableInflater.inflateFromXml(DrawableInflater.java:130)
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1224)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java:1197)
at com.android.layoutlib.bridge.impl.ResourceHelper.getDrawable(ResourceHelper.java:315)
at android.content.res.BridgeTypedArray.getDrawable(BridgeTypedArray.java:681)
at android.widget.CompoundButton.<init>(CompoundButton.java:89)
at android.widget.CheckBox.<init>(CheckBox.java:70)
at android.widget.CheckBox.<init>(CheckBox.java:66)
at android.widget.CheckBox.<init>(CheckBox.java:62)
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 android.view.LayoutInflater.createView(LayoutInflater.java:645)
at android.view.BridgeInflater.onCreateView(BridgeInflater.java:107)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:717)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:785)
at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:149)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:858)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:834)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:317)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:429)
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:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Aakriti Gupta
  • 802
  • 1
  • 7
  • 16

8 Answers8

133

UPDATE Sep/2016

Issue is no longer reproducible on Android Studio v2.2. Update your Android Studio and the issue will be no longer reproducible.

UPDATE Aug/2016

Issue is still happening in Android Studio v2.1.3

Original Answer

It seems this is an issue and it is being handled by google HERE:

Some other people are facing the same issue and the fix is always to change the preview API from 24 to 23 (or any other version).

You may need to download a previous version of SDK.. You don't need to change your build.gradle... Just download the SDK and Android Studio will allow you to change the SDK in Layout Preview

enter image description here

guipivoto
  • 18,327
  • 9
  • 60
  • 75
  • Had the same issue myself. Thanks for the answer! – Strahinja Ajvaz Sep 02 '16 at 07:39
  • Happening here also. iOS > Android – Jared Sep 02 '16 at 18:54
  • Using API 23 or lower 'fix the issue'. I just wanna add this happens if I try to define `` for Android with API 15 or lower to have a 'return' button located at the action bar. If I remove this ``, the rendering happens smoothly. I will update my AS to version 2.2 and see if it fix the issue as soon as the package maintainer of my *nix distro release it (main stable branch). – José Sep 21 '16 at 16:29
  • I mean, add this into my `AndroidManifest.xml`. Considering the proper activity, of course. – José Sep 21 '16 at 16:43
4

Rendering Problem Related Issue is Resolved Check out the Answer here that says

android studio pick Automatically Pick Best by default

so you have to select previous one API 23 manually.

Community
  • 1
  • 1
Inzimam Tariq IT
  • 6,548
  • 8
  • 42
  • 69
1

You can try to change the AppTheme.

  • This worked for me. I selected AppTheme manually instead of the default Light and it got fixed – Donki Jan 18 '23 at 13:57
1

I have similar issue and resolve it by manage pixel sizes of drawables and width-height of controls in xml file. Please do not add any controls in xml file which is not used in class file.

1

I had a similar problem. I resolved it by decreasing the size of the images in the drawable folder.

rya
  • 1,417
  • 1
  • 16
  • 29
0

I have selected the previous version as suggested but still did not see the previous image.

What I did was this:

  1. In the list of versions selected the " previous version " and "Preview Androids Versions " .

  2. Once the screens appear earlier versions of android I click on one of the previous and drag on the image layout that does not images.

To me it worked well , I hope and serve them . We're reading .

0

I was using API 22, though API 25 was available on my System.

Moving the problematic tab between different split views did the trick in a second.

nyxee
  • 2,773
  • 26
  • 22
0

I've had this exception before and what worked for me was File -> Invalidate Caches/Restart.

You may try that, but you should know that all of the Local History will be deleted.

Edit: Downgrading from API 24 to API 23 also works.

Raza Javeid
  • 23
  • 10