渲染期间引发的异常:二进制XML文件行#-1:错误膨胀类<unknown>

时间:2016-07-23 16:43:53

标签: android android-layout android-fragments

image of problem

我尝试在布局中包含复选框,拖放后我收到此错误:

  渲染期间引发的

异常:二进制XML文件行#-1:错误   膨胀public static void main(String[] args) throws FileNotFoundException, IOException { FileReader fr = new FileReader("\\pathtofile\\data.txt"); BufferedReader br = new BufferedReader(fr); int nextLetter; int[] count = new int[26]; int total = 0; int other = 0; System.out.println("Letter Frequency"); while ((nextLetter = br.read()) != -1) { char current = (char) nextLetter; current = Character.toLowerCase(current); if (current >= 'a' && current <= 'z') { count[current - 'a']++; total++; } else { other++; } } Map ans = sorting(count); printMap(ans); } private static Map sorting(int[] count) { Map m = new LinkedHashMap<String, Integer>() {}; int k = 0 ; for (int i = 0; i < 26; i++) { int max =-1; for (int j = 0; j < 26; j++) { if(max < count[j]){ max = count[j]; k = j; } } count[k] = -1; if(max!=0) m.put(((char)(k+97))+"", max); max=0; } return m; } public static void printMap(Map<String, Integer> map) { for (Entry<String, Integer> entry : map.entrySet()) { System.out.println("" + entry.getKey() + " : "+ entry.getValue()); } }

xml文件:

class<unknown>

请提供一步一步的解决方案。

详情链接说:

<?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>

8 个答案:

答案 0 :(得分:132)

2016年9月更新

问题在Android Studio v2.2上不再可重现。更新您的Android Studio,问题将不再可重现。

2016年8月更新

Android Studio v2.1.3中仍然存在问题

原始答案

这似乎是一个问题,它由谷歌HERE处理:

其他一些人正面临同样的问题,修复方法总是将预览API从24更改为23(或任何其他版本)。

您可能需要下载以前版本的SDK .. 您无需更改build.gradle ...只需下载SDK,Android Studio即可让您更改SDK在布局预览中

enter image description here

答案 1 :(得分:4)

渲染问题相关问题已解决Check out the Answer here,表示

  

android studio选择 A utomatically P ick B 默认

因此您必须手动选择上一个API 23

答案 2 :(得分:1)

我有类似的问题,并通过管理xml文件中的drawables的像素大小和控件的width-height来解决它。请不要在xml文件中添加任何未在类文件中使用的控件。

答案 3 :(得分:1)

我有类似的问题。我通过减小drawable文件夹中图像的大小来解决它。

答案 4 :(得分:0)

我按照建议选择了以前的版本,但仍未看到上一张图片。

我做的是:

  1. 在选择的版本列表中,&#34;以前的版本&#34;和&#34;预览Androids版本&#34;

  2. 一旦屏幕出现早期版本的android,我点击其中一个,然后拖动没有图像的图像布局。

  3. 对我而言,它运作良好,我希望并为他们服务。我们正在阅读。

答案 5 :(得分:0)

我使用的是API 22,虽然我的系统上提供了API 25。

在不同的拆分视图之间移动有问题的标签会在一秒钟内完成。

答案 6 :(得分:0)

我之前有这个例外,对我有用的是File - &gt;使高速缓存/重新启动无效。

您可以尝试,但您应该知道所有本地历史记录都将被删除。

编辑:从API 24降级到API 23也有效。

答案 7 :(得分:-1)

您可以尝试更改AppTheme。