我已经更新了我的Android应用程序以使用androidx支持库,在本地运行时一切正常,使用google运行自动测试也可以。 当用户在google play中更新时,问题就开始发生,只是不断崩溃。卸载并重新安装该应用程序即可解决问题。
我也很难在本地复制此图片,但是我可以使用一部不断崩溃的手机,该手机一直与Google Play上的更新版本冲突。
据我所知,问题与放大视图有关
2019-03-27 09:58:58.667 1975-1975/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.myapp.android, PID: 1975
android.view.InflateException: Binary XML file line #17: Binary XML file line #1: Error inflating class <unknown>
Caused by: android.view.InflateException: Binary XML file line #1: 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:658)
at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:64)
at com.android.internal.policy.HwPhoneLayoutInflater.onCreateView(HwPhoneLayoutInflater.java:107)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:731)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:799)
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:976)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:870)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:835)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:877)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:835)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:877)
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:974)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:870)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:835)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at androidx.appcompat.app.f.b(AppCompatDelegateImpl.java:469)
at androidx.appcompat.app.c.setContentView(AppCompatActivity.java:141)
at com.myapp.android.ui.main.MainActivity.G(MainActivity.java:1224)
at com.myapp.android.ui.main.MainActivity.a(MainActivity.java:106)
at com.myapp.android.ui.main.MainActivity$2.a(MainActivity.java:291)
at com.myapp.android.ui.main.MainActivity$2.onChanged(MainActivity.java:283)
at androidx.lifecycle.LiveData.b(LiveData.java:113)
at androidx.lifecycle.LiveData.a(LiveData.java:131)
at androidx.lifecycle.LiveData.b(LiveData.java:289)
at androidx.lifecycle.p.b(MutableLiveData.java:33)
at androidx.lifecycle.LiveData$1.run(LiveData.java:91)
at android.os.Handler.handleCallback(Handler.java:808)
at android.os.Handler.dispatchMessage(Handler.java:101)
at android.os.Looper.loop(Looper.java:166)
at android.app.ActivityThread.main(ActivityThread.java:7425)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)
Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 13: TypedValue{t=0x2/d=0x7f0400b4 a=-1}
at android.content.res.TypedArray.getDrawableForDensity(TypedArray.java:996)
at android.content.res.TypedArray.getDrawable(TypedArray.java:980)
at android.view.View.<init>(View.java:4746)
at android.view.ViewGroup.<init>(ViewGroup.java:597)
at android.widget.LinearLayout.<init>(LinearLayout.java:237)
at android.widget.LinearLayout.<init>(LinearLayout.java:233)
at android.widget.LinearLayout.<init>(LinearLayout.java:229)
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
at android.view.LayoutInflater.createView(LayoutInflater.java:658)
at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:64)
at com.android.internal.policy.HwPhoneLayoutInflater.onCreateView(HwPhoneLayoutInflater.java:107)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:731)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:799)
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:976)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:870)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:835)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:877)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:835)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:877)
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:974)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:870)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:835)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at androidx.appcompat.app.f.b(AppCompatDelegateImpl.java:469)
at androidx.appcompat.app.c.setContentView(AppCompatActivity.java:141)
at com.myapp.android.ui.main.MainActivity.G(MainActivity.java:1224)
at com.myapp.android.ui.main.MainActivity.a(MainActivity.java:106)
at com.myapp.android.ui.main.MainActivity$2.a(MainActivity.java:291)
at com.myapp.android.ui.main.MainActivity$2.onChanged(MainActivity.java:283)
at androidx.lifecycle.LiveData.b(LiveData.java:113)
at androidx.lifecycle.LiveData.a(LiveData.java:131)
at androidx.lifecycle.LiveData.b(LiveData.java:289)
at androidx.lifecycle.p.b(MutableLiveData.java:33)
at androidx.lifecycle.LiveData$1.run(LiveData.java:91)
at android.os.Handler.handleCallback(Handler.java:808)
at android.os.Handler.dispatchMessage(Handler.java:101)
at android.os.Looper.loop(Looper.java:166)
at android.app.ActivityThread.main(ActivityThread.java:7425)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)
我不确定行是否正确,但是错误在这里发生
private void initMainActivity() {
setContentView(R.layout.activity_main);
我已经尝试通过该应用程序来确保我们没有引用任何旧的支持库。 也已设置
android.useAndroidX=true
android.enableJetifier=true
,没有任何结果。
任何想法,因为我们在这里迷路了。
仅当从Google Play更新到此版本时才会发生这种情况,而不是通过在多个设备和操作系统版本上进行的全新安装在本地测试应用程序时进行。
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<layout 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">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="false"
android:clipToPadding="false"
android:fitsSystemWindows="true"
android:orientation="vertical"
tools:context="com.myapp.android.ui.main.MainActivity">
<include layout="@layout/activity_top_section" />
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="top"
android:animateLayoutChanges="true"
android:clipToPadding="false"
android:elevation="-1dp"
android:orientation="vertical"
android:paddingBottom="@dimen/bottom_bar_height"
android:visibility="visible"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<include
android:id="@+id/activity_bottom_section"
layout="@layout/activity_bottom_section" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
activity_top_section.xml
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipChildren="false"
android:clipToPadding="false"
android:paddingTop="@dimen/appbar_padding_top"
android:stateListAnimator="@null"
android:theme="@style/AppTheme.AppBarOverlay">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="@dimen/toolbar_height"
android:layout_weight="1"
android:gravity="center"
android:minHeight="@dimen/toolbar_height"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/AppTheme.PopupOverlay">
<include
android:id="@+id/activity_top_section_toolbar_search"
layout="@layout/activity_top_section_toolbar_search" />
<FrameLayout
android:id="@+id/toolbar_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
app:layout_scrollFlags="scroll|enterAlways" />
<ImageView
android:id="@+id/toolbar_image"
android:layout_width="@dimen/search_image_view_width"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:contentDescription="@string/image_view_content"
android:src="@drawable/logo_black"
android:visibility="gone" />
<TextView
android:id="@+id/toolbar_title"
style="@style/FontText.Large"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:ellipsize="end"
android:gravity="center"
android:maxLines="1"
android:visibility="gone" />
</androidx.appcompat.widget.Toolbar>
<FrameLayout
android:id="@+id/appbar_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="0dp"
app:layout_scrollFlags="scroll|enterAlways" />
</com.google.android.material.appbar.AppBarLayout>
activity_bottom_section.xml
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<FrameLayout
android:id="@+id/bottom_navigation_view"
android:layout_width="wrap_content"
android:layout_height="@dimen/bottom_bar_parent_height"
android:layout_gravity="bottom">
<View
android:id="@+id/shadow_view"
android:layout_width="match_parent"
android:layout_height="@dimen/default_margin_extra_large"
android:layout_gravity="top"
android:background="@drawable/shadow" />
<com.aurelhubert.ahbottomnavigation.AHBottomNavigation
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_bar_height"
android:layout_gravity="bottom"
android:background="?attr/colorBgLight"
app:itemIconTint="@drawable/navigation_icon_color"
app:menu="@menu/navigation_menu" />
</FrameLayout>