添加radiobuttons时出现问题

时间:2016-08-19 16:16:36

标签: android xml android-studio

无法理解错误。

但是它可以构建应用程序,我可以启动它。

enter image description here

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:layout_height="match_parent">


    <TextView
        android:id="@+id/test"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="16dp"
        android:layout_marginRight="16dp"/>

    <RadioGroup
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal">

        <RadioButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="New RadioButton"
            android:id="@+id/radioButton"/>

        <RadioButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="New RadioButton"
            android:id="@+id/radioButton2"/>
    </RadioGroup>


</LinearLayout>

如何解决?

来自我的gradle文件的信息:

...
compileSdkVersion 24
buildToolsVersion "24.0.1"

defaultConfig {
   ...
    minSdkVersion 16
    targetSdkVersion 24
    versionCode 1
    versionName "1.0"
...
  

java.lang.NoSuchMethodError:android.graphics.drawable.VectorDrawable_Delegate.nCreateTreeFromCopy(JJ)J       在android.graphics.drawable.VectorDrawable.nCreateTreeFromCopy(VectorDrawable.java)       在android.graphics.drawable.VectorDrawable.access $ 400(VectorDrawable.java:204)       在android.graphics.drawable.VectorDrawable $ VectorDrawableState.createNativeTreeFromCopy(VectorDrawable.java:837)       在android.graphics.drawable.VectorDrawable $ VectorDrawableState。(VectorDrawable.java:812)       在android.graphics.drawable.VectorDrawable.mutate(VectorDrawable.java:268)       在android.graphics.drawable.DrawableContainer $ DrawableContainerState.addChild(DrawableContainer.java:817)       在android.graphics.drawable.StateListDrawable $ StateListState.addStateSet(StateListDrawable.java:329)       在android.graphics.drawable.AnimatedStateListDrawable $ AnimatedStateListState.addStateSet(AnimatedStateListDrawable.java:602)       在android.graphics.drawable.AnimatedStateListDrawable.parseItem(AnimatedStateListDrawable.java:525)       在android.graphics.drawable.AnimatedStateListDrawable.inflateChildElements(AnimatedStateListDrawable.java:453)       在android.graphics.drawable.AnimatedStateListDrawable.inflate(AnimatedStateListDrawable.java:385)       在android.graphics.drawable.DrawableInflater.inflateFromXml(DrawableInflater.java:130)       在android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1224)       在android.graphics.drawable.Drawable.createFromXml(Drawable.java:1197)       在com.android.layoutlib.bridge.impl.ResourceHelper.getDrawable(ResourceHelper.java:315)       在android.content.res.BridgeTypedArray.getDrawable(BridgeTypedArray.java:681)       在android.widget.CompoundButton。(CompoundButton.java:89)       在android.widget.RadioButton。(RadioButton.java:63)       在android.widget.RadioButton。(RadioButton.java:59)       在android.widget.RadioButton。(RadioButton.java:55)       at sun.reflect.GeneratedConstructorAccessor275.newInstance(Unknown Source)       at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)       at java.lang.reflect.Constructor.newInstance(Constructor.java:422)       在android.view.LayoutInflater.createView(LayoutInflater.java:645)       在android.view.BridgeInflater.onCreateView(BridgeInflater.java:107)       在android.view.LayoutInflater.onCreateView(LayoutInflater.java:717)       在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:785)       在android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:149)       在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)       在android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:858)       在android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)       在android.view.LayoutInflater.rInflate(LayoutInflater.java:834)       在android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)       在android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:861)       在android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)       在android.view.LayoutInflater.rInflate(LayoutInflater.java:834)       在android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)       在android.view.LayoutInflater.inflate(LayoutInflater.java:518)       在android.view.LayoutInflater.inflate(LayoutInflater.java:397)       在com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:317)       在com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:429)       在com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:350)       在com.android.tools.idea.rendering.RenderTask $ 2.compute(RenderTask.java:520)       在com.android.tools.idea.rendering.RenderTask $ 2.compute(RenderTask.java:508)       在com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:967)       在com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:508)       在com.android.tools.idea.rendering.RenderTask.access $ 600(RenderTask.java:75)       在com.android.tools.idea.rendering.RenderTask $ 3.call(RenderTask.java:620)       在com.android.tools.idea.rendering.RenderTask $ 3.call(RenderTask.java:617)       在com.android.tools.idea.rendering.RenderService.runRenderAction(RenderService.java:371)       在com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:617)       在com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:639)       在com.intellij.android.designer.designSurface.AndroidDesignerEditorPanel $ 7.run(AndroidDesignerEditorPanel.java:519)       在com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:337)       在com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:327)       在com.intellij.util.ui.update.MergingUpdateQueue $ 3.run(MergingUpdateQueue.java:271)       在com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:286)       在com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:244)       在com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:234)       在com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)       在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)       在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)       at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617)       在java.lang.Thread.run(Thread.java:745)

2 个答案:

答案 0 :(得分:1)

见这里: exception raised during rendering:Binary XML file line #-1:error inflating class<unknown> 通过SDK管理器安装SDK 23并选择它进行预览,对我来说很有用。

答案 1 :(得分:0)

<RadioGroup
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_vertical"   
    android:orientation="vertical">

    <RadioButton
        android:id="@+id/btn0"
        android:layout_width="90dp"
        android:layout_height="35dp"
        android:button="@null"
        android:gravity="center"/>

    <RadioButton
        android:id="@+id/btn1"
        android:layout_width="90dp"
        android:layout_height="35dp"
        android:button="@null"
        android:gravity="center" />

</RadioGroup>