【问题标题】:Exception raised during rendering: java.lang.System.arraycopy渲染期间引发异常:java.lang.System.arraycopy
【发布时间】:2014-06-27 12:08:35
【问题描述】:

我对新的 ADT 版本有一个奇怪的问题。我已经从eclipse.org 下载了新的 Eclipse,然后我在上面安装了 ADT。一切正常;我可以为 android 创建一个项目,一切正常,除了:

在尝试创建一个 xml 布局时,我收到以下错误:

Exception raised during rendering: java.lang.System.arraycopy

在错误日志中我看到:

Failed to render set of icons for AnalogClock, AutonCompleteTextView, button, SmallButton , ....

我将EditText 更改为TextView,错误消失了。即使出现此警告,我也可以运行我的程序,但我想在图形部分查看我的布局。

我的布局是:

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

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="50"
        android:gravity="right"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/close"
            android:layout_width="50dp"
            android:layout_height="match_parent"
            android:background="#00000000" />
    </LinearLayout>

    <View
        android:id="@+id/view1"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_weight="20" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="40"
        android:orientation="horizontal"
        android:weightSum="320" >

        <View
            android:id="@+id/view8"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="40" />

        <EditText
            android:id="@+id/textView1"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="240"
            android:gravity="center|right"
            android:background="#00000000"/>

        <View
            android:id="@+id/view9"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="40" />
    </LinearLayout>

    <View
        android:id="@+id/view2"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="20" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="35"
        android:orientation="horizontal" >

        <View
            android:id="@+id/view10"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="40" />

        <EditText
            android:id="@+id/textView2"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="240"
            android:gravity="center|right"
            android:background="#00000000" />

        <View
            android:id="@+id/view11"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="40" />
    </LinearLayout>

    <View
        android:id="@+id/view3"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_weight="10" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="35"
        android:orientation="horizontal" >

        <View
            android:id="@+id/view12"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="40" />

        <EditText
            android:id="@+id/textView3"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="240"
            android:gravity="center|right"
            android:background="#00000000"/>

        <View
            android:id="@+id/view13"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="40" />
    </LinearLayout>

    <View
        android:id="@+id/view4"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_weight="105" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="40"
        android:orientation="horizontal" >

        <View
            android:id="@+id/view14"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="40" />

        <EditText
            android:id="@+id/textView4"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="240"
            android:gravity="center|right"
            android:background="#00000000" />

        <View
            android:id="@+id/view15"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="40" />
    </LinearLayout>

    <View
        android:id="@+id/view5"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="5" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="40" >

        <View
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="40"
             />

        <EditText
            android:id="@+id/textView6"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="240"
            android:gravity="center|right"
            android:background="#00000000" />

        <View
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="40" />
    </LinearLayout>

    <View
        android:id="@+id/view6"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="20" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="30"
        android:orientation="horizontal"
        android:weightSum="320" >

        <View
            android:id="@+id/view16"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="90" />

        <CheckBox
            android:id="@+id/shake"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:layout_weight="70"
            android:gravity="center" />

        <View
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="10" />

        <CheckBox
            android:id="@+id/ring"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:layout_weight="70"
            android:gravity="center" />

        <View
            android:id="@+id/view17"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="80" />
    </LinearLayout>

    <View
        android:id="@+id/view7"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="30" />

</LinearLayout>

我在这里搜索了答案,但没有找到任何答案。我怎样才能解决这个问题?

PS:这个问题发生在 ADT 23 上 - 我用 ADT 22.6 试了一下,效果很好。

【问题讨论】:

  • 您正在使用高级别的嵌套权重。嵌套权重不利于性能。这可能是原因
  • 我不这么认为@IllegalArgument,因为正如我所说,如果我使用 TextView 问题已经消失了。无论如何如何在不使用高级嵌套权重的情况下创建这种布局?
  • 您是否尝试过清理您的项目?也许 R. 文件已损坏?
  • 是的@erik 我试过打扫和其他所有事情,
  • 可能是因为你的 weightSum 错误(我从来没有用过 weightSum 所以...)

标签: android eclipse


【解决方案1】:

这个问题发生在 API 20 (Android 4.4 W) 我最近遇到了一个问题,但问题将通过将用于渲染级别的 Android 版本从 API 20 (Android 4.4 W) 更改为 API 19 (Android 4.4. 2)(图形布局右上角的android图标)或将您的SDK更新为Android L(API 20 L预览)

屏幕截图:

【讨论】:

  • 在我的机器上,重启了 android studio,然后显示 API 20 Android L 的选项(并且可以添加文本字段而不会出错)
  • 2016 更新:这完美地解决了我的问题。 Android N(预览版)是新安装 Android Studio 的默认设置。更改为 API 23 会立即显示屏幕。
【解决方案2】:

Android Wear 是一款手表,您无法在其中输入任何内容,因此您无法在 4.4W 上使用 EditText。将 API 更改为 19 或更低或将其更改为 4.4L,可从 SDK Manager 下载。这不是错误。

【讨论】:

    【解决方案3】:

    我在使用 20 (4.4W) 时遇到了同样的问题,但是当我安装并选择 20 (4.4 L (preview)) 时它就消失了。这可能是因为 4.4W 是 Android Wear SDK,因此可能不支持标准手机/平板 Android 的所有功能

    【讨论】:

      【解决方案4】:

      @shayan pourvatan 已经为我正确回答了这个问题,我只是添加了这两张图片,描述了如何安装 API 20 L 版本,然后将其用作预览渲染器。

      【讨论】:

        【解决方案5】:

        您可以将 4.4W SDK 更新为 4.4W2 SDK。 那个固定我的。

        【讨论】: