I'm trying to use TextInputEditText from Material Design (https://github.com/material-components/material-components-android/blob/master/docs/components/TextInputLayout.md) and I'm getting runtime exception.
This's part of run log:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.grigori.materialtextedit, PID: 12036
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.grigori.materialtextedit/com.example.grigori.materialtextedit.MainActivity}: android.view.InflateException: Binary XML file line #9: Binary XML file line #9: Error inflating class com.google.android.material.textfield.TextInputLayout
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: android.view.InflateException: Binary XML file line #9: Binary XML file line #9: Error inflating class com.google.android.material.textfield.TextInputLayout
Caused by: android.view.InflateException: Binary XML file line #9: Error inflating class com.google.android.material.textfield.TextInputLayout
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.material.textfield.TextInputLayout" on path: DexPathList
I cut this log by DexPathList that contains many paths to apk files, like:
zip file "/data/app/com.example.grigori.materialtextedit-jamgTcrgG9neBKIMcqDo7Q==/base.apk"
My xml file:
<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">
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/hint_text"/>
</com.google.android.material.textfield.TextInputLayout>
My build.gradle dependences:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
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'}
Faced this issue when implementing AndroidX in my existing project.
implementation 'com.google.android.material:material:1.0.0-beta01'
Layout XML
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/userNameWrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/TextLabel">
Old Style
<style name="TextLabel" parent="TextAppearance.AppCompat">
<item name="android:textColorHint">@color/hint_color</item>
<item name="android:textSize">@dimen/text_20sp</item>
<item name="colorControlNormal">@color/primaryGray</item>
<item name="colorControlActivated">@color/colorPrimary</item>
</style>
New Style
<style name="TextLabel" parent="Widget.MaterialComponents.TextInputLayout.FilledBox">
<item name="android:textColorHint">@color/hint_color</item>
<item name="android:textSize">@dimen/text_20sp</item>
<item name="colorControlNormal">@color/primaryGray</item>
<item name="colorControlActivated">@color/colorPrimary</item>
</style>