1

I am very new to android develop & Android Studio. I was trying to create a simple app with a text input field so that that user can input text. (Again very new to this and just messing around with android development/studio).

Anyway, when I've added the 'TextInputLayout' and then a input text field from the palette, I get the above error.

I have tried to refresh as hinted to me. Also tried uninstalling Android Studio, different APKs. I have tried some solutions from another post on stack-overflow by looking through the manifest file and the style.xml files and haven't had any luck.

Was wondering if anyone could help me resolve this issue again I am extremely new to android development and Programming in general, so it may be an easy fix but I've ran out of ideas LOL.

Below is the code I currently have my 'activity_main.xml' file.

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<android.support.design.widget.TextInputLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <EditText
        android:id="@+id/editText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:ems="10"
        android:hint="@string/input_text"
        android:inputType="text" />

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

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115

3 Answers3

5

This is an android studio bug with dependencies of support library. I also faced same problem few days ago.

  • Go to build.gradle file (inside app folder).

  • Then change the version of dependencies of support library -- replace 28.0.1-alpha3 to 28.0.1-alpha1

  • Then go to styles.xml file (at app/res/values folder) and add this item in your style named AppTheme.
    <item name="textInputStyle">@style/Widget.Design.TextInputLayout</item>

Anuj Kumar
  • 1,092
  • 1
  • 12
  • 26
0

In addition to above users answer, if you are unsure about how to determine which certain version of the support library you should upgrade or downgrade, let Android Studio choose that best applies to you. Simply target it by putting .+ symbol right after the main version of the library, which works pretty well for me.

Go to Gradle Scripts, open build.gradle(Module:app), replace the version of support library dependencies as following:

dependencies {
    implementation 'com.android.support:appcompat-v7:28.+'
}

enter image description here

and then go to styles.xml file located at app/res/values folder and add this item
<item name="textInputStyle">@style/Widget.Design.TextInputLayout</item>in your style named AppTheme. .

<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">

    <item name="textInputStyle">@style/Widget.Design.TextInputLayout</item>
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

enter image description here

Hope it helps to others, too. Let me know

Boken
  • 4,825
  • 10
  • 32
  • 42
Gulbala Salamov
  • 198
  • 3
  • 9
0

First if you create themes in res file so, locate it in manifest file with android:theme="@style/Theme.xyz" and in the layout design you have to check the same theme is applied there or not.

Giulio Caccin
  • 2,962
  • 6
  • 36
  • 57
MEGHA DOBARIYA
  • 1,622
  • 9
  • 7