0

I'm trying to add TextInputLayout for Android Material Design Floating Labels for EditText.

I have added implementation 'com.android.support:design:28.0.0' which shows to add *

noinspection GradleCompatible

My build.gradle as below

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "29.0.2"


    defaultConfig {
        applicationId "com.example.writeproctor"
        minSdkVersion 21
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility = 1.8
        targetCompatibility = 1.8
    }

}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    //noinspection GradleCompatible
    implementation 'com.android.support:design:28.0.0'
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.13'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

I have suppressed the warning but still not able add TextInputLayout.

How can i add TextInputLayout in this latest android studio 3.5.3?

1 Answers1

3

if you wanna use implementation 'com.android.support:design:28.0.0' then you should replace

implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

with

implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'
implementation 'com.android.support.constraint:constraint-layout:1.1.1'

Your error happens because androidX and android support is different versions of android libraries and you trying to use them both, support library is depricated, so it is recommended by Google to use AndroidX. You better don't use 'com.android.support:design:28.0.0' Replace it with

implementation 'com.google.android.material:material:1.0.0'

Btw guy here gave a complete answer what is Support and AndroidX libraries how it correlate with each other and etc.

  • 1
    Your solution also works fine. I have forcefully stopped the Android Studio IDE and restarted before updating your changes. It worked. –  Jan 25 '20 at 12:16
  • Glad to help, bud, in fact in a lot of cases you can use Build-Rebuild/Clean project instead of restarting Android Studio, try) – Danila says Reinstate Monica Jan 25 '20 at 12:19