Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error when using any Android Design Support Library Elements

Error inflating anything from the design support library

xml

<android.support.design.widget.FloatingActionButton         android:layout_width="wrap_content"         android:layout_height="wrap_content"/> 

build.gradle

dependencies {     compile 'com.android.support:support-v4:22.2.0'     compile 'com.android.support:design:22.2.0'     compile 'com.android.support:multidex:1.0.1'     compile 'com.android.support:support-v13:22.2.0'     compile 'com.android.support:appcompat-v7:22.2.0' 

project build.gradle

buildscript {     repositories {         mavenCentral()     }     dependencies {         classpath 'com.android.tools.build:gradle:1.2.3'     } }  allprojects {     repositories {         mavenCentral()     } } 

Error:

Binary XML file line #115: Error inflating class android.support.design.widget.FloatingActionButton 

My Sdk Manager everything is up to date.
SDK Manager

like image 893
Joshua McWilliams Avatar asked May 30 '15 14:05

Joshua McWilliams


People also ask

What is Android Design Support Library?

The Design Support library adds support for various material design components and patterns for app developers to build upon, such as navigation drawers, floating action buttons (FAB), snackbars, and tabs. The Gradle build script dependency identifier for this library is as follows: com. android.

Which of the following library supports storage Android?

The AndroidX library contains the existing support library and also includes the latest Jetpack components. You can continue to use the support library. Historical artifacts (those versioned 27 and earlier, and packaged as android. support.


2 Answers

In addition to Emmanuel's answer you could be facing the following problem.

It seems like the design library components need a style which is based on an AppCompat Theme. So try to use "Theme.AppCompat.[...]" as a parent in your style.xml.

Example:

<!-- Base application theme. --> <style name="AppTheme" parent="Base.AppTheme">     <!-- Customize your theme here. --> </style>  <style name="Base.AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">     <item name="android:colorPrimary">@color/primary</item>     <item name="android:colorPrimaryDark">@color/primary_dark</item>     <item name="android:colorAccent">@color/accent</item> </style> 

Then add the following to your build.gradle as well:

compile 'com.android.support:appcompat-v7:22.2.0' 

Additionally you should update the following lines in your gradle as well:

classpath 'com.android.tools.build:gradle:1.2.3' compileSdkVersion 22 buildToolsVersion '22.0.1' targetSdkVersion 22 
like image 90
CptSausage Avatar answered Oct 25 '22 09:10

CptSausage


Update Support Library on SDK Manager in Extras > Android Support Repository and Android Support Library, that works for me ;)

and dont forget to add the compile 'com.android.support:design:22.2.0' on app.gradle and sync

like image 38
ponnex Avatar answered Oct 25 '22 10:10

ponnex