从Android Studio中的Refactor工具迁移到AndroidX后,出现此错误- android.view.InflateException:二进制XML文件第42行:错误膨胀类..
在我工作完美之前,但只有在迁移之后,它才会在某些活动中出现这些错误。
StackTrace:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.pumosoft.naveenkadiyala.familychoice/com.pumosoft.naveenkadiyala.familychoice.Login}: android.view.InflateException: Binary XML file line #42: Error inflating class <unknown>
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: android.view.InflateException: Binary XML file line #42: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:633)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.pumosoft.naveenkadiyala.familychoice.Login.onCreate(Login.java:44)
at android.app.Activity.performCreate(Activity.java:5990)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:607)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.pumosoft.naveenkadiyala.familychoice.Login.onCreate(Login.java:44)
at android.app.Activity.performCreate(Activity.java:5990)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0xffffffff
at android.content.res.Resources.getValue(Resources.java:1266)
at androidx.appcompat.content.res.AppCompatResources.isColorInt(AppCompatResources.java:163)
at androidx.appcompat.content.res.AppCompatResources.inflateColorStateList(AppCompatResources.java:110)
at androidx.appcompat.content.res.AppCompatResources.getColorStateList(AppCompatResources.java:76)
at com.google.android.material.textfield.TextInputLayout.<init>(TextInputLayout.java:366)
at com.google.android.material.textfield.TextInputLayout.<init>(TextInputLayout.java:247)
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:607)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.pumosoft.naveenkadiyala.familychoice.Login.onCreate(Login.java:44)
at android.app.Activity.performCreate(Activity.java:5990)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
I/Process: Sending signal. PID: 15330 SIG: 9
Application terminated.
我的XML代码:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout 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" android:background="@drawable/bg__gradient" android:orientation="vertical" tools:context=".Login"> <TextView android:id="@+id/log_title" android:layout_width="match_parent" android:layout_height="@dimen/_150sdp" android:fontFamily="@font/berkshire_swash" android:gravity="center" android:text="@string/app_name" android:textColor="#fff" android:textSize="@dimen/_47ssp" /> <com.google.android.material.textfield.TextInputLayout android:id="@+id/log_email" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="@dimen/_10sdp" android:layout_marginRight="@dimen/_10sdp" android:layout_marginBottom="@dimen/_10sdp" android:textColorHint="#fff" app:errorTextAppearance="@style/error_appearance" app:hintTextAppearance="@style/TextAppearance.App.TextInputLayout"> <com.google.android.material.textfield.TextInputEditText android:layout_width="match_parent" android:layout_height="wrap_content" android:fontFamily="@font/ubuntu_light" android:hint="@string/email" android:inputType="textEmailAddress" android:textColor="#fff" app:backgroundTint="#fff" /> </com.google.android.material.textfield.TextInputLayout> <com.google.android.material.textfield.TextInputLayout android:id="@+id/log_password" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="@dimen/_10sdp" android:layout_marginRight="@dimen/_10sdp" android:layout_marginBottom="@dimen/_10sdp" android:textColorHint="#fff" app:errorTextAppearance="@style/error_appearance" app:hintTextAppearance="@style/TextAppearance.App.TextInputLayout" app:passwordToggleEnabled="true" app:passwordToggleTint="#FFF"> <com.google.android.material.textfield.TextInputEditText android:layout_width="match_parent" android:layout_height="wrap_content" android:fontFamily="@font/ubuntu_light" android:hint="@string/password" android:inputType="textPassword" android:textColor="#fff" app:backgroundTint="#fff" /> </com.google.android.material.textfield.TextInputLayout> <TextView android:id="@+id/Login_forgotPass_btn" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginRight="@dimen/_10sdp" android:layout_marginBottom="@dimen/_10sdp" android:gravity="right" android:text="@string/forget_password" android:textColor="#FFF" android:textSize="@dimen/_15ssp" android:textStyle="bold" /> <androidx.cardview.widget.CardView android:id="@+id/log_log_card" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="@dimen/_15sdp" android:layout_marginRight="@dimen/_15sdp" android:layout_marginBottom="@dimen/_10sdp" app:cardBackgroundColor="#fff" app:cardCornerRadius="@dimen/_8sdp"> <TextView android:id="@+id/log_login_btn" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:paddingTop="@dimen/_5sdp" android:paddingBottom="@dimen/_5sdp" android:text="@string/cap_login" android:textColor="@android:color/holo_orange_dark" android:textSize="@dimen/_20ssp" android:textStyle="bold" /> </androidx.cardview.widget.CardView> <androidx.cardview.widget.CardView android:id="@+id/log_reg_card" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="@dimen/_15sdp" android:layout_marginRight="@dimen/_15sdp" app:cardBackgroundColor="#fff" app:cardCornerRadius="@dimen/_8sdp"> <TextView android:id="@+id/log_signup_btn" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:paddingTop="@dimen/_5sdp" android:paddingBottom="@dimen/_5sdp" android:text="@string/cap_register" android:textColor="@android:color/holo_orange_dark" android:textSize="@dimen/_20ssp" android:textStyle="bold" /> </androidx.cardview.widget.CardView> </LinearLayout>
答案 0 :(得分:1)
答案 1 :(得分:0)
问题看起来像这样。
a201,[XYZ1 - XYZXYZ, XYZXYZ]
f110,[XYZ1 - XYZXYZ, XYZXYZ]
a202,[XYZ2 - XYZXYZ, XYZXYZ]
f110,[XYZ2 - XYZXYZ, XYZXYZ]
顺便说一句,我假设您已经在build.gradle中定义了支持设计库
app:errorTextAppearance="@style/error_appearance"
app:hintTextAppearance="@style/TextAppearance.App.TextInputLayout
答案 2 :(得分:0)
我遇到了同样的问题,使我整整疯了一天。我发现res文件夹中的样式文档具有其他版本(v19和v23),尽管已在常规样式表中进行了修复,但它们的主题仍然具有appcompat。我刚刚删除了其他样式表,它就起作用了。