android - Xamarin Studio (Android) 错误膨胀类 <unknown> 除非清理

标签 android android-layout xamarin.android xamarin-studio inflate-exception

问题:

在 Xamarin Studio 中修改我的 Android 项目中的任何 布局文件后,我的 mainlauncher (SplashActivity) 抛出以下异常。异常继续抛出,直到我清理我的项目。


异常:

Binary XML file line #17: Error inflating class

Exception being thrown


环境:

我正在使用以下工具:

Xamarin Studio: Version 5.2.1 (build 1)
Xamarin.Android: Version 4.1.0

具有以下相关设置:

Minimum Android Version: Android 4.3 (API level 16)

计算机:

Windows 7 Home Premium SP1 (x64)

测试设备:

Samsung Galaxy S4 running Android 4.3


相关代码:

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

我的研究:

以下是看似相关但与我当前情况无关的问题列表。


附加信息:

  • 当我在调试前清理解决方案时,错误得到解决,直到我修改任何 布局文件。
  • 一旦抛出此异常,它将继续抛出,直到我清理解决方案。
  • Activity 的 XML 只有一个 TextView ,它不调用任何可绘制资源。此外,SplashLayout.axml 仅包含 12 行代码。

问题:

  • 可能导致此错误的原因是什么,它会在生产中发生吗?

最佳答案

您能否尝试将这一行添加到您的 axml 文件中: xmlns:app="http://schemas.android.com/apk/res-auto"

这听起来可能无关紧要,但我曾经遇到过通货膨胀问题,并且通过这样做得到了解决。

关于android - Xamarin Studio (Android) 错误膨胀类 <unknown> 除非清理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25408901/

相关文章:

java - 使用位图设置墙纸避免裁剪并设置适合中心

java - 找不到符号方法 setAnimationListener

安卓发送邮件

android - 选中时 NavigationView 的颜色

c# - BitmapFactory.DecodeStream 上的 Android 单声道退出代码 255

c# - MonoDroid : Path to Assets to unzip a file with . 网络框架

xamarin.android - MonoDroid 如何在布局 axml 文件中使用自定义属性?

android - ActionBarCompat : add separator between menu items

java - 使用 Gson 和改造的 Java 的 Json 错误 [预期为 BEGIN_ARRAY,但在第 1 行第 70 列路径 $.Data 处为 BEGIN_OBJECT]

android - 使用 RxJava 遍历 ViewGroup child