本文介绍了膨胀类com.android.internal.widget.ActionBarContainer时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,最近,由于.移动并解决我在运行项目时遇到的其他错误之后,应用程序崩溃,并出现 android.view.InflateException:二进制XML文件第31行:错误膨胀了com.android.internal.widget.ActionBarContainer 类.不幸的是,我无法发布logcat消息,因为它太大而无法发布,因此我将在此处放置一些 Caused by 消息.除了膨胀异常外,其他两个异常是:由以下原因引起:java.lang.reflect.InvocationTargetException 由以下原因导致:java.lang.RuntimeException:无法解析索引13处的属性.所有异常和错误本身均引用类的 setContentView(R.layout.activity_automatic_floor_plan_loader); .在此布局文件中,我正在使用 AppTheme.AppBarOverlay .我很确定一切都与此应用程序有关,但是我不知道要更改什么以及如何进行更改.我经历了很多Stackoverflow问题,但是似乎都没有一个答案或解决我遇到的错误.这是我的Style.xml文件:

So, recently I had to move my project from where it was due to the Error: File path too long on windows, keep below 240 characters.After moving, and solving other errors when I run my project, the app crashes with android.view.InflateException: Binary XML file line #31: Error inflating class com.android.internal.widget.ActionBarContainer. Unfortunately, I cannot post the logcat message as it is too big to post, so I will just put some Caused by messages here.Apart from the inflate exception the other two exceptions are: Caused by: java.lang.reflect.InvocationTargetException and Caused by: java.lang.RuntimeException: Failed to resolve attribute at index 13. All of the exceptions and the error itself refers to a class' setContentView(R.layout.activity_automatic_floor_plan_loader);. In this layout file I am using AppTheme.AppBarOverlay. I am quite sure everything relates to this apptheme, but I do not know what to change and how to. I have gone through many Stackoverflow questions, but none of them seems to answer or solve the error I am getting. Here is my Style.xml file:

这是Android-Manifest.xml文件中我班的活动:

And here is my class' activity in the Android-Manifest.xml file:

这是我的activity.xml(activity_automatic_floor_plan_loader):

And here is my activity.xml (activity_automatic_floor_plan_loader):

这是我的build.gradle(app)文件:如何解决这个错误?非常感谢.

And here is my build.gradle(app) file:How to solve this error? Many thanks.

推荐答案

这是我解决此错误的方法:

Here is how I solved this error:

  1. 在styles.xml文件中,在第一个"AppTheme"样式中,我必须将Base放在Theme.AppCompat的前面.因此它将是"Base.Theme.AppCompat.Light.DarkActionBar".

  1. In the styles.xml file, in the first "AppTheme" style I had to put Base infront of Theme.AppCompat. So it would be "Base.Theme.AppCompat.Light.DarkActionBar".

然后我在androidmanifest.xml的父级活动中使用了android:theme ="@ style/AppTheme".

Then I used android:theme="@style/AppTheme" in my parent activity in androidmanifest.xml.

在子活动的androidmanifest文件中,我必须放入android:parentActivityName =.parentActivity",然后从子活动中删除了android:theme ="@ style/AppTheme.AppBarOverlay"并将其放入如下所示的activity.xml(子活动)文件.

In the androidmanifest file in the child activity, I had to put android:parentActivityName=".parentActivity" and I removed android:theme="@style/AppTheme.AppBarOverlay" from the child activity and put it in the activity.xml (child activity) file as below.

在LinearLayout标签中的activity.xml文件中,我必须放置android:theme ="@ style/ThemeOverlay.AppCompat.Dark.ActionBar".它是"@ style/AppTheme.AppBarOverlay"的父级.

In the activity.xml file in the LinearLayout tag, I had to put android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar". It is the parent of the "@style/AppTheme.AppBarOverlay".

这4个步骤对我有用,如果您遇到此错误,请按照以下步骤操作,它也应该对您有用.

This 4 step process worked for me, and if you are getting this error, just follow these steps and it should work for you as well.

修改:事实证明,解决方案非常简单.要在任何活动中都有操作栏,只需扩展AppCompatActivity.只有我的主要活动是扩展AppCompatActivity,而不是其他活动.上面获取动作条的方法非常模糊,但是我知道它起初是可行的,但是现在我有了正确而直接的解决方案,如果遇到这种错误,则只需检查是否在您的应用程序中扩展了AppCompatActivity即可.上课与否.

Edit:It turned out that the solution was very simple. To have an action bar in any of your activities, you just need to extend AppCompatActivity. Only my main activity was extending AppCompatActivity and not other activities. The above approach for getting an action bar is quite vague and I knew it, however, it worked initially, but now I have the correct and straight forward solution and if you are getting such error then just check that whether you are extending AppCompatActivity in your class or not.

这篇关于膨胀类com.android.internal.widget.ActionBarContainer时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 12:34