jit thakore
jit thakore

Reputation: 95

Error inflating anything from the design support library

I am trying to implement floating labels in edit text which requires com.android.support:design: 23.0.1 but the design support library is not getting compiled.

Here is my build.gradle for app and project. Please point out mistakes or give suggestions.

build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.searchable"
        minSdkVersion 14
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:22.1.1'
    compile 'com.android.support:design:22.2.0'
}

PROJECT build.gradle

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

    }
}

allprojects {
    repositories {
        jcenter()
    }

ERROR

Error:(24, 13) Failed to resolve: com.android.support:design:22.2.0

I also tried downloading the jar file and including it as a library. The compilation in this case does not pose any problem but the XML file returns the following error during build.

XMl

 <android.support.design.widget.TextInputLayout

    android:id="@+id/input_layout_password"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">


    <EditText
        android:id="@+id/input_password"
        android:inputType="textPassword"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="password" />

</android.support.design.widget.TextInputLayout>

ERROR

The following class cannot be instantiated -android.support.design.TextInputLayout(Open Class, Show Exception, Clear Cache)

When I click on Open Class link the jar decompiler shows the class source code, so I am assuming that thee is no problem in including the library.

EDIT

I found out that there is a problem in including any dependency in Gradle and it returns the same compilation error irrespective of the library included.

Upvotes: 0

Views: 150

Answers (2)

Kush
Kush

Reputation: 1092

May be it will help you as I tried in this case.. Put in Gradle dependencies.

        dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'  
compile 'com.android.support:design:22.2.0'
  }

And that you have intialized like this

TextInputLayout Password;
Password= (TextInputLayout) findViewById(R.id.input_password);

Thanks..

Upvotes: 0

Murli Prajapati
Murli Prajapati

Reputation: 9733

Change your compileSdkVersion to 23 and add this to app level build.gradle file
compile 'com.android.support:design:23.4.0'

Upvotes: 1

Related Questions