Error inflating class android support v7 widget toolbar

Inflating class android.support.v7.widget.Toolbar and application crashes #333

Comments

nocturnalprelude commented Dec 11, 2014

Launching the DemoActivity, the application crashes with this message:

Could not find method android.support.v4.view.ViewConfigurationCompat.hasPermanentMenuKey, referenced from method android.support.v7.app.ActionBarActivityDelegateBase.openPanel**

12-11 15:52:46.621: E/AndroidRuntime(1051): FATAL EXCEPTION: main
12-11 15:52:46.621: E/AndroidRuntime(1051): java.lang.RuntimeException: Unable to start activity ComponentInfo: android.view.InflateException: Binary XML file line #23: Error inflating class android.support.v7.widget.Toolbar
12-11 15:52:46.621: E/AndroidRuntime(1051): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2295)
12-11 15:52:46.621: E/AndroidRuntime(1051): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2349)
12-11 15:52:46.621: E/AndroidRuntime(1051): at android.app.ActivityThread.access$700(ActivityThread.java:159)
12-11 15:52:46.621: E/AndroidRuntime(1051): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)
12-11 15:52:46.621: E/AndroidRuntime(1051): at android.os.Handler.dispatchMessage(Handler.java:99)
12-11 15:52:46.621: E/AndroidRuntime(1051): at android.os.Looper.loop(Looper.java:176)
12-11 15:52:46.621: E/AndroidRuntime(1051): at android.app.ActivityThread.main(ActivityThread.java:5419)
12-11 15:52:46.621: E/AndroidRuntime(1051): at java.lang.reflect.Method.invokeNative(Native Method)
12-11 15:52:46.621: E/AndroidRuntime(1051): at java.lang.reflect.Method.invoke(Method.java:525)
12-11 15:52:46.621: E/AndroidRuntime(1051): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046)
12-11 15:52:46.621: E/AndroidRuntime(1051): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862)
12-11 15:52:46.621: E/AndroidRuntime(1051): at dalvik.system.NativeStart.main(Native Method)
12-11 15:52:46.621: E/AndroidRuntime(1051): Caused by: android.view.InflateException: Binary XML file line #23: Error inflating class android.support.v7.widget.Toolbar
12-11 15:52:46.621: E/AndroidRuntime(1051): at android.view.LayoutInflater.createView(LayoutInflater.java:626)
12-11 15:52:46.621: E/AndroidRuntime(1051): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:702)
12-11 15:52:46.621: E/AndroidRuntime(1051): at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
12-11 15:52:46.621: E/AndroidRuntime(1051): at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
12-11 15:52:46.621: E/AndroidRuntime(1051): at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
12-11 15:52:46.621: E/AndroidRuntime(1051): at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
12-11 15:52:46.621: E/AndroidRuntime(1051): at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
12-11 15:52:46.621: E/AndroidRuntime(1051): at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
12-11 15:52:46.621: E/AndroidRuntime(1051): at android.support.v7.app.ActionBarActivityDelegateBase.setContentView(ActionBarActivityDelegateBase.java:228)
12-11 15:52:46.621: E/AndroidRuntime(1051): at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:102)
12-11 15:52:46.621: E/AndroidRuntime(1051): at com.sothree.slidinguppanel.demo.DemoActivity.onCreate(DemoActivity.java:29)
12-11 15:52:46.621: E/AndroidRuntime(1051): at android.app.Activity.performCreate(Activity.java:5372)
12-11 15:52:46.621: E/AndroidRuntime(1051): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104)
12-11 15:52:46.621: E/AndroidRuntime(1051): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2257)
12-11 15:52:46.621: E/AndroidRuntime(1051): . 11 more
12-11 15:52:46.621: E/AndroidRuntime(1051): Caused by: java.lang.reflect.InvocationTargetException
12-11 15:52:46.621: E/AndroidRuntime(1051): at java.lang.reflect.Constructor.constructNative(Native Method)
12-11 15:52:46.621: E/AndroidRuntime(1051): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
12-11 15:52:46.621: E/AndroidRuntime(1051): at android.view.LayoutInflater.createView(LayoutInflater.java:600)
12-11 15:52:46.621: E/AndroidRuntime(1051): . 24 more
12-11 15:52:46.621: E/AndroidRuntime(1051): Caused by: java.lang.NoSuchMethodError: android.support.v4.content.ContextCompat.getDrawable
12-11 15:52:46.621: E/AndroidRuntime(1051): at android.support.v7.internal.widget.TintManager.getDrawable(TintManager.java:133)
12-11 15:52:46.621: E/AndroidRuntime(1051): at android.support.v7.internal.widget.TintTypedArray.getDrawable(TintTypedArray.java:62)
12-11 15:52:46.621: E/AndroidRuntime(1051): at android.support.v7.widget.Toolbar.(Toolbar.java:249)
12-11 15:52:46.621: E/AndroidRuntime(1051): at android.support.v7.widget.Toolbar.(Toolbar.java:191)
12-11 15:52:46.621: E/AndroidRuntime(1051): . 27 more

The text was updated successfully, but these errors were encountered:

Источник

Ошибка раздувания класса android.support.v7.widget.Toolbar?

Я пытаюсь получить Material Design для своего приложения, выполнив этот метод.

Всякий раз, когда я запускаю приложение, он показывает следующую ошибку:

Ошибка раздувания класса android.support.v7.widget.Toolbar.

Я проверил, правильно ли я добавил appcompat. Но для меня все правильно. Поэтому, пожалуйста, скажите мне, что я делаю неправильно?

build.gradle

Logcat

ИЗМЕНИТЬ

toolbar.xml

activity_main.xml

ОТВЕТЫ

Ответ 1

Извините парней. Я давно решил этот вопрос. Я сделал много изменений. Поэтому я не могу понять, какой из них делает трюк.

Я изменил идентификатор, как предложил Джаред Берроуз.

Удалили мою библиотеку поддержки и очистили мой проект и добавили его.

Перейдите в Файл → Недействительный кэш/Перезапуск.

Надеюсь, что это сработает.

Вот как выглядит мой код сейчас

activity.xml

toolbar_default.xml

ToolBarStyle

Ответ 2

Мне удалось решить эту проблему, заменив следующее:

В макете панели инструментов замените все, что угодно:

Ответ 3

У меня была такая же проблема, как и при использовании версии AppCompat Library версии 23.2.0. Я обновил библиотеку suppport до 23.2.1, и проблема была решена.

Эта проблема панели инструментов была решена в 23.2.1

Ответ 4

Кроме того, вы даете ему тот же «ID» дважды, пожалуйста, удалите «id» из вашего include:

Ответ 5

Проблема заключается в том, что вы используете неправильную тему, вы можете выбрать тему, которая нравится Theme.AppCompat.NoActionBar, в моем проекте она работает.

Я надеюсь вам помочь.

Ответ 6

Я сталкиваюсь с той же проблемой, но это произошло после того, как я обновился до appcompatv23.2.0 . Я пробовал все вышеперечисленные предложения, но работал. Затем я перешел к моему файлу Gradle и заменил:

Восстановите проект, и проблема исчезла. Это может быть проблемой с app compact v23.2.0, надеюсь, лучшее решение подходит, чтобы мы могли работать с новым обновлением.

Надеюсь, это поможет. Спасибо.

Ответ 7

Чтобы устранить эту проблему. сначала вы должны добавить поддержку lastandroid-support-v7-appcompat из каталога \sdk\extras\android\support

  • Закройте основной проект.
  • Удалите поддержку android-support-v7-appcompat.
  • Перезапустите Eclipse.
  • Добавьте поддержку android-support-v7-appcompat.
  • Очистить, Чтобы построить проект.
  • Затем откройте основной проект и постройте все проекты.
  • Ошибка все еще сохраняется. Перезапустить затмение. Это он.
Читайте также:  Лаунчеры для андроид с жестами

Это работает для меня, и я настоятельно рекомендую вам использовать Android Studio.

Ответ 8

Я исправил эту проблему, изменив файл app build.gradle.

Для Gradle Плагин 2.0+

Для Gradle Плагин 1.5

Ответ 9

Я столкнулся с такой же проблемой. Решение, которое сработало для меня. Если вы используете v7.Toolbar, вы должны использовать тему, расширенную из Theme.AppCompat. * Вы не можете использовать тему, расширенную от android: Theme.Material. * Потому что они имеют разные атрибуты стиля.

Надеюсь, что это поможет.

Ответ 10

Это сработало для меня: Добавить компилировать ‘com.android.support:appcompat-v7:21.0.3’ в gradle. Измените цель sdk на 21. Надеемся, что это сработает для вас!

Ответ 11

У меня были проблемы, включая панель инструментов в RelativeLayout, попробуйте с LinearLayout. Если вы хотите наложить панель инструментов, попробуйте:

Я не понимаю, почему, но это работает для меня.

Ответ 12

Непонятно, почему эта ошибка произошла со мной, но я решил. Я использовал тот же макет, в строке или с помощью include, оба они вызывают ошибку NPE. Поэтому я думаю, что это не проблема макета.

У меня был вызов абстрактного класса. BaseActivity расширяет ActionBarActivity, у которого есть метод initActionBar(). Я переопределяю и вызываю этот метод в OnCreate дочернего класса. Что-то вроде этого:

У меня была ошибка NPE с вышедшим кодом. Я НЕ ЗНАЮ, ПОЧЕМУ Я НЕПРАВИЛЬНО. Я РЕШАЯ НИЖЕ КОДА И ИСКАТЬ СЕЙЧАС.

Ответ 13

В моем случае проблема заключалась в вызове функции inflater.inflate(R.layout.some_layout, null). Ошибка в параметре ViewGroup.

Ответ 14

Решение проблемы для меня было найдено в документе XML для моей основной деятельности. Первоначально моя панель инструментов была . Чтобы решить эту проблему, я изменил ее на . Я не знаю, почему это сработало. Кто-нибудь знает, почему?

Ответ 15

Я удалил эти строки, как показано ниже:

Вместо «@attr/actionBarSize» установите конкретные размеры, это работает для меня.

Ответ 16

Для меня это сработало после того, как я сделал:

  • Очищающее решение.
  • Удаление приложения с телефона, на которое я отлаживал его.
  • Закрытие Visual Studio.
  • Удаление папок/bin/и/obj/в проектах Android.
  • Запуск решения снова.

Источник

ÇøŋfuzëÐ SøurcëÇødë

This is The ÇøŋfuzëÐ SøurcëÇødë, the Software Engineer. That hyper-active, over enthusiastic, radical developer you may have heard about! This is just a simple attempt to put the source code confusion of my life into words! (^_^)

Let’s Solve, Error inflating class android.support. v7.widget.Toolbar …

So the other day I created a new Xamarin Forms solution in Visual Studio for one of my sample apps, and tried to build and run it.

Something to keep a note here my

  • VS – Xamarin Version – 4.2.2.1
  • VS – Xamarin Android Version – 7.0.2.42
  • Xamarin Forms Version – 2.3.3.180

Build and Run, worked perfectly on iOS.

but on Android?

Then I tried running the Android app, and suddenly at runtime, KABOOM!

Android.Views.InflateException: Binary XML file line #1: Error inflating class android.support.v7.widget.Toolbar…

Without even any build errors, a fresh out of the box project in Visual Studio!

It seemed like some Android dlls were missing in the runtime, something to do with Toolbar. 😮

This didn’t make any sense because I haven’t done any modifications to the project or even written any single line of code in the project, this was just a fresh out of the box Xamarin Forms solution.

So as usual I tried Clean & Rebuild, Restart VS, Restart the PC and so on many other random stuff. But still couldn’t figure out.

A WEIRD SOLUTION!

So as of a final destination I tried downgrading the Xamarin Forms version in the solution, and BOOM! IT WORKED!

So I thought may be this was a bug in the Xamarin Forms version I was using, but just to clarify it I upgraded the Xamarin Forms version back to the original version.

and BOOM! IT WORKED! 😀

Right Click on the Solution -> Manage Nugest Packages -> Select Xamarin.Forms package -> Tick on all the Projects in your Solution -> go to the Version selector -> select a lower Xamarin.Forms version and click Install -> restart VS -> Clean & Rebuild

Then do the same process but when you’re selecting the Xamarin.Forms version, make sure to select the one you had originally at first place when you created your solution! 😉

Читайте также:  Map on android maps api

Probably…

Although this doesn’t really make any sense why it would throw such a runtime error, fresh out of the box, and then magically fixes after downgrading and upgrading back the Xamarin Forms version in the solution, but I’m guessing its something to do with the Xamarin Extension for Visual Studio, which might be messing up with adding some Android dependencies to the solution.

Anyways, I just posted this in any case if you ever came across such a situation yourself! 😀

Источник

Error inflating class android support v7 widget toolbar

Asked by:

Question

I am creating a Xamarin Forms Project and using android.support.v7.widget.Toolbar with FormsAppCompatActivity. The code I’m posting below was working with Xamarin.Android.Support.v7.AppCompat Version: 23.0.1.3

But after I upgraded to 23.3.0 this has started throwing Android.Views.InflateException: Binary XML file line #1: Error inflating class android.support.v7.widget.toolbar exception.

Here is my code for MainActivity

This is my code for Resource.Layout.toolbar

All replies

Did you upgrade Xamarin Forms to a version compatible with 23.3?

I have updated Xamarin.Forms to 2.2.0.31

Dependencies for this version of Xamarin Forms mention: MonoAndroid 1.0 Xamarin.Android.Support.v4 (= 23.3.0) Xamarin.Android.Support.Design (= 23.3.0) Xamarin.Android.Support.v7.AppCompat (= 23.3.0) Xamarin.Android.Support.v7.CardView (= 23.3.0) Xamarin.Android.Support.v7.MediaRouter (= 23.3.0)

it should thus be compatible with 23.3.

Hi, I have the same problem with Xamarin.Forms 2.3.0.38-pre2 compatible with Xamarin.Android.Support.v7.AppCompat (= 23.3.0). Have you found a solution? Thanks!

Try the following:

  1. Manually remove each of the NuGet package one by one in the Android project only. You may have to do multiple passes of removing them due to dependency.
  2. Restart VS
  3. Then just add Xamarin.Forms package only. All the necessary packages will be added automatically.
  4. Clean and rebuild the project.

I don’t guarantee that it will definitely work. But it is one of the possible solutions.

. already done without success! 🙁 And the project has 36 nuget packages. very boring! Same error with Visual Studio on Parallels and Xamarin Studio on mac.

Has anyone had the same problem? 🙁

This is really a blocker now. I had to roll back the whole update. If anyone has a solution, please share.

link to bugzilla: https://bugzilla.xamarin.com/show_bug.cgi?id=41380

Issue is not occurring after upgrading to Xamarin.Forms 2.2.0.45

Not here. 🙁 I upgraded to 2.3.0.46 pre3 (I need beta channel for some features) and the problem still persists. Please Xamarin help.

Did you do a full clean and rebuild? Try to delete the bin and obj folders. Usually cleans it up

@JamesMontemagno said: Did you do a full clean and rebuild? Try to delete the bin and obj folders. Usually cleans it up

This worked for me!

@JamesMontemagno said: Did you do a full clean and rebuild? Try to delete the bin and obj folders. Usually cleans it up

Worked for me as well. Thanks James.

In some cases this is just caused by missing the the android:theme in the Application tag of the android manifest.

Additional info here: https://bugzilla.xamarin.com/show_bug.cgi?id=41380

@JamesMontemagno said: Did you do a full clean and rebuild? Try to delete the bin and obj folders. Usually cleans it up

work for me as well. Upgraded to 2.3.0.107

In my case, my styles.xml had issues

Changed API level to API 19 after that no issue before API 24

I GOT THE SAME ERROR, BUT TRYING ALL DIFFERENT THINGS SUGGESTED IN DIFFERENT THREADS IN DIFFERENT LOCATIONS I TRIED BELOW.

THIS WORKED FOR ME.

DELETED «Xamarin.Android.Support.v7.AppCompat» FOLDER FROM LOCATION «C:\Users\AppData\Local\Xamarin»

THIS IS FOR WINDOWS NOT SURE ABOUT IF YOU ARE DEVELOPING IN MAC MACHINE

I found that this error occurs only when running on an API 22 virtual device. It doesn’t occur when I deploy to an API 19 virtual device. I’m using the default blank project generated by VS2015 without any modifications.

I have the same issue and cleaning the project, deleting obj/bin did not help. What I have discovered is that certain API targets don’t work and that means it’s likely a bug in «Xamarin.Android.Support.v7.AppCompat».

Specifically I get the error when trying to debug on Android 5.0 — API 21. Both the Galaxy S4 emulator and physical device have the same error. However, Android 4.2 — API 17, and Android 6.0 — API 21 both work fine. For now I will debug on a working emulator but hopefully this gets fixed soon.

Читайте также:  Как сделать черные обои андроид

@JamesMontemagno , Thank you. It worked for me 🙂

I downgraded from 2.3.3.180 to 2.3.3.168 and now the app runs.

@anve You’re right. It works by downgrading from 2.3.3.180 to 2.3.3.168

I was deploying to a Samsung tablet with Api level 22 and threw the same error. After downgraded, it worked.

The above suggestion worked for me as well. However, at the moment nothing works anymore. not even when I create an app with the wizard and run it immediately. The Xamarin environment in combination with Visual Studio 2015 seems to be very unstable

in my case issue was this —

Android.Views.InflateException: Binary XML file line #1: Error inflating class android.support.v7.widget.Toolbar

and switching from Virtual device API 22 to API 19 solved the issue.

I also faced same issue in Xamarin Forms App. the issue was solved by downgrading Xamarin Forms from 2.3.3.180 to 2.3.3.175 which I got from this URL https://bugzilla.xamarin.com/show_bug.cgi?id=41380

I encountered same problem but I was able to solve the problem by running the project in API > 22 (Android 6+) or

I’m facing the same problem. Does that mean that Android 22 users will not be able tu use my app? Is there any hope to see a fix in a near futur? Who should be contacted?

Facing the same problem, I had tried all the solution mention above, but no luck, found out that when I updating the Xamarin Form to 2.3.3.193 by using NuGet package manager, after the installation, restart the visual studio, clean the solution and rebuild the solution. After that, when I try to debug to my device which is android 5.1 API 21 and praise to God it works!

@ManojShukla said: I GOT THE SAME ERROR, BUT TRYING ALL DIFFERENT THINGS SUGGESTED IN DIFFERENT THREADS IN DIFFERENT LOCATIONS I TRIED BELOW.

THIS WORKED FOR ME.

DELETED «Xamarin.Android.Support.v7.AppCompat» FOLDER FROM LOCATION «C:\Users\AppData\Local\Xamarin»

THIS IS FOR WINDOWS NOT SURE ABOUT IF YOU ARE DEVELOPING IN MAC MACHINE

I tried everything else and it’s the only solution that worked for me ! I’m on Android 5.1 — API 22

The folder appeared after the next build, so i suppose the error could come back .

nothing worked for me, i tried to downgrade xamarin forms and nothing, tried to upgrade and nothing, tried deleting appcompat and nothing, i dont know what else to do =(

I’m facing de same error. I was using Xamarin.Forms.2.3.3.175 version and now I’ve upgraded to Xamarin.Forms.2.3.3.193 version. Then it works successfullly.

Hey all! Recent occurrences of this error message or similar ones were most likely caused by a bug in the templates where not all the dependencies for Forms were added in the Android project. This is why updating/downgrading the Forms package would resolve the issue as it would pull in the correct dependencies.

This bug has been fixed in the C9 stable release so if you are encountering this error or similar issues with the latest version of Xamarin, please create a new thread and provide as much detail as possible so we can look into it. Thanks!

@justwooper As mentioned above, can you open a new thread for your issue and include the full text of any errors you may be seeing and also the Forms version you are using and your IDE version information? Thanks!

@ShantimohanElchuri said: Try the following:

  1. Manually remove each of the NuGet package one by one in the Android project only. You may have to do multiple passes of removing them due to dependency.
  2. Restart VS
  3. Then just add Xamarin.Forms package only. All the necessary packages will be added automatically.
  4. Clean and rebuild the project.

I don’t guarantee that it will definitely work. But it is one of the possible solutions.

This worked for me. Thank you.

@James Montemagno Thanks for your solution. It is worked fine.

@JamesMontemagno said: Did you do a full clean and rebuild? Try to delete the bin and obj folders. Usually cleans it up

Источник

Оцените статью