问题:
在 Xamarin Studio 中修改我的 Android 项目中的任何布局文件后,我的 mainlauncher (SplashActivity) 会引发以下异常。异常继续抛出,直到我清理我的项目。
例外:
二进制 XML 文件第 17 行:膨胀类时出错
环境:
我正在使用以下工具:
Xamarin Studio: Version 5.2.1 (build 1)
Xamarin.Android: Version 4.1.0
使用以下相关设置:
最低 Android 版本:Android 4.3(API 级别 16)
计算机:
Windows 7 家庭高级版 SP1 (x64)
测试设备:
运行 Android 4.3 的三星 Galaxy S4
相关代码:
SplashLayout.axml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:text="Loading..."
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/SPLASH_messageText" />
</LinearLayout>
SplashActivity(修剪为仅 OnCreate):
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
SetContentView (Resource.Layout.SplashLayout); // <-- this is where the exception is thrown
MessageTextView = FindViewById<TextView> (Resource.Id.SPLASH_messageText); // Get a reference to our message text view to update the user
ThreadPool.QueueUserWorkItem (o => {
InitialChecking(); // Check to make sure Google Play services are installed
});
} // end OnCreate
我的研究:
以下是看似相关但与我目前的情况无关的问题列表。
- Xamarin - 二进制 XML 文件第 1 行:错误膨胀类-错误是由使用颜色状态列表作为背景引起的。我什至没有定义背景。
- 二进制 XML 文件第 17 行:错误膨胀类-此错误是由于使用该
android:attr/textAppearanceListItemSmall
属性而针对不支持它的 API 级别(>14)。我的最低 Android 版本是 API 级别 16。 - InflateException: Binary XML file line #1: Error inflating class -问题是由资源解码导致 VM 内存不足的大位图引起的。我没有加载任何图像或绘图。
- 二进制 XML 文件第 9 行:膨胀类片段时出错-我没有使用片段
- android.view.InflateException: Binary XML file line #6: Error inflating class - *OP was using depreciated
AbsoluteLayout
,我正在使用LinearLayout
- EditText 标记导致错误膨胀类-错误是由 引起的
android:scrollY="10dp"
,这不在我的布局中。
附加信息:
- 当我在调试之前清理解决方案时,错误得到解决,直到我修改任何布局文件。
- 一旦抛出此异常,它将继续抛出,直到我清理解决方案。
- 活动的 XML 只有一个文本视图,它不调用任何可绘制资源。此外,
SplashLayout.axml
仅包含 12 行代码。
问题:
- 什么可能导致这个错误,它会在生产中发生吗?