我正在使用最新版本的androidx和androidx。 我的应用程序中有一个TextInputLayout,这会使该应用程序在添加任何样式时崩溃!
这是xml的一部分:
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/textInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/saveNameID"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.material.textfield.TextInputLayout>
这是logcat错误:
2019-01-30 22:41:59.537 1980-1980/hossein.yusefpour.sinamobile E/AndroidRuntime: FATAL EXCEPTION: main
Process: hossein.yusefpour.sinamobile, PID: 1980
android.view.InflateException: Binary XML file line #51: Binary XML file line #51: Error inflating class <unknown>
Caused by: android.view.InflateException: Binary XML file line #51: Error inflating class <unknown>
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
at android.view.LayoutInflater.createView(LayoutInflater.java:647)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790)
.
.
.
at androidx.fragment.app.FragmentManagerImpl$1.run(FragmentManagerImpl.java:147)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:169)
at android.app.ActivityThread.main(ActivityThread.java:6578)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: java.lang.IllegalArgumentException: The style on this component requires your app theme to be Theme.MaterialComponents (or a descendant).
at com.google.android.material.internal.ThemeEnforcement.checkTheme(ThemeEnforcement.java:240)
at com.google.android.material.internal.ThemeEnforcement.checkMaterialTheme(ThemeEnforcement.java:215)