16

I am getting this error:

Cannot resolve symbol '@style/Widget.MaterialComponents.TextInputLayout.OutlineBox'

I am getting this error after I added this line to my TextInputLayout in my XML:

style="@style/Widget.MaterialComponents.TextInputLayout.OutlineBox" 

This is my full XML code(removed unrelevant constraints/margins):

<android.support.design.widget.TextInputLayout
    android:id="@+id/textInputLayout2"
    style="@style/Widget.MaterialComponents.TextInputLayout.OutlineBox"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    app:counterEnabled="true"
    app:counterMaxLength="300">

    <android.support.design.widget.TextInputEditText
        android:id="@+id/cheese_description"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="start"
        android:hint="@string/cheese_description" />

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

this is my app build.gradle:

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "app.cheese.cheese.some.sample_cheese"
        minSdkVersion 19
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    buildToolsVersion '27.0.3'
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.google.firebase:firebase-auth:11.8.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    compile 'com.android.support:design:27.0.2'
    compile 'com.google.firebase:firebase-core:11.8.0'
    implementation 'com.android.support:appcompat-v7:27.0.2'
    compile 'com.android.support:support-v4:27.0.2'
    compile 'com.google.firebase:firebase-storage:11.8.0'
    compile 'com.google.firebase:firebase-messaging:11.8.0'
    compile 'com.firebaseui:firebase-ui-auth:3.1.3'
    compile 'com.google.firebase:firebase-database:11.8.0'
    implementation 'com.android.support:cardview-v7:27.0.2'
    implementation 'com.android.support:recyclerview-v7:27.0.2'
    implementation 'com.firebaseui:firebase-ui-database:3.2.1'
}

apply plugin: 'com.google.gms.google-services'

and this is my other build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath 'com.google.gms:google-services:3.1.1'


        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

I tried:

  • changing buildToolsVersions from "27.0.3" to "27.0.2" and sync
  • Invalidate Caches/ Restart
  • Rebuild Project

I took the XML line of code that causes error from the material.io components here. does anyone know what I am doing wrong?

Thank you :)

Richard Miller
  • 576
  • 1
  • 7
  • 18

8 Answers8

9

The Material Components have not yet shipped new releases under the com.android.support:design dependency as of yet (or via any other official dependency you can include in your build.gradle file) so what you're seeing in 27.0.2 does not contain any of the recent changes - such as support for Widget.MaterialComponents.TextInputLayout.OutlineBox.

You'll have to copy the portions of the Material Components library you want directly into your project if you want access to the latest changes.

ianhanniballake
  • 191,609
  • 30
  • 470
  • 443
  • Thank you! do you have a guide on how to accomplish that? I am just starting out – Richard Miller Feb 04 '18 at 01:02
  • 3
    Unfortunately, it isn't quite as straightforward as one would like - you'd want to copy the [lib directory](https://github.com/material-components/material-components-android/tree/master/lib) into the root of your project, then edit your `settings.gradle` to most of the code from [their settings.gradle](https://github.com/material-components/material-components-android/blob/master/settings.gradle). Personally, I'd probably just stick to the things already launched as part of the `com.android.support:design` dependency, particularly if you are just starting out. – ianhanniballake Feb 04 '18 at 01:52
8

Both of answers are right but i found an error by the codelabs given code on this link https://codelabs.developers.google.com/codelabs/mdc-111-kotlin/#2 The OutlineBox is misspelled the correct code is

style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
Husnain Qasim
  • 189
  • 2
  • 7
5

If you use new packaging for support libraries you should use:

com.google.android.material:material:1.0.0-beta01 dependency for that

Filipkowicz
  • 639
  • 6
  • 17
4

add below dependency solved my problem

implementation 'com.android.support:design:28.0.0'

my full dependencies is

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.android.support:design:28.0.0'

}
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
saigopi.me
  • 14,011
  • 2
  • 83
  • 54
4

Somehow off-your-question, but to clarify on the Material stuff (it can help anyone on migrating to the Material Design intro),

Change your app theme to inherit from a Material Components theme

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- ... -->
</style>

to

<style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
    <!-- ... -->
</style>

for more information visit

Getting started with Material Components for Android

Joseph Wambura
  • 2,732
  • 2
  • 21
  • 24
2

This style is from the part of design support library v28 alpha version and it is not released yet until android p release. For to use this change compileSdkVersion to 'android-P' and use this dependency to use it

implementation 'com.android.support:design:28.0.0-alpha1'
IntelliJ Amiya
  • 74,896
  • 15
  • 165
  • 198
Karthick Ramanathan
  • 642
  • 3
  • 9
  • 20
1

Make sure that in your AndroidManifest.xml file, you have a materialcomponents as theme for your Activity. Some thing like this:

<activity android:name=".activities.LoginActivity"
          android:screenOrientation="portrait"
          android:theme="@style/Theme.MaterialComponents.Light.NoActionBar">
</activity>
0

I'm getting same issue I solved using below dependencies

Use Below dependencies

implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'
implementation 'com.android.support:design:28.0.0-alpha3
AskNilesh
  • 67,701
  • 16
  • 123
  • 163