由 Android 10 API 级别 29 上的 android.view.InflateException 引起

发布于 2025-01-10 10:55:33 字数 5975 浏览 2 评论 0原文

我的应用程序在每个 API 级别上运行,但有时无法在某些特定设备上加载。 这次它无法找到华为设备上已有的资源,设备详细信息如下:

Build.DEVICE : HWJNY 
Build.FINGERPRINT : HUAWEI/JNY-LX1/HWJNY:10/HUAWEIJNY-L21/10.1.0.388C432:user/release-keys 
Build.HARDWARE : kirin810 
Build.PRODUCT : JNY-LX1 
Location : RO 
Brand:HUAWEI
Model:JNY-LX1
Orientation: Portrait
RAM free: 1.57 GB
Disk free: 103.26 GB
Operating system
Version:Android 10
Orientation: Portrait
Rooted:No

Stacktrace:

Non-fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.package/com.package.onboarding.VerifyPhoneNumberActivity}: android.view.InflateException: Binary XML file line #49 in com.package:layout/activity_verify_phone_number_new: Binary XML file line #49 in com.package:layout/activity_verify_phone_number_new: Error inflating class androidx.appcompat.widget.AppCompatImageView
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3897)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4076)
       at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:91)
       at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:149)
       at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:103)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2473)
       at android.os.Handler.dispatchMessage(Handler.java:110)
       at android.os.Looper.loop(Looper.java:219)
       at android.app.ActivityThread.main(ActivityThread.java:8349)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1055)

更多到stacktrace:

Caused by android.content.res.Resources$NotFoundException: Resource ID #0x7f080271
       at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:328)
       at android.content.res.Resources.getValue(Resources.java:1468)
       at androidx.appcompat.widget.ResourceManagerInternal.createDrawableIfNeeded(ResourceManagerInternal.java:179)
       at androidx.appcompat.widget.ResourceManagerInternal.getDrawable(ResourceManagerInternal.java:144)
       at androidx.appcompat.widget.ResourceManagerInternal.getDrawable(ResourceManagerInternal.java:135)
       at androidx.appcompat.content.res.AppCompatResources.getDrawable(AppCompatResources.java:104)
       at androidx.appcompat.widget.AppCompatImageHelper.loadFromAttributes(AppCompatImageHelper.java:63)
       at androidx.appcompat.widget.AppCompatImageView.<init>(AppCompatImageView.java:82)
       at androidx.appcompat.widget.AppCompatImageView.<init>(AppCompatImageView.java:69)
       at java.lang.reflect.Constructor.newInstance0(Constructor.java)
       at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
       at android.view.LayoutInflater.createView(LayoutInflater.java:864)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1016)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:971)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:1133)
       at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1094)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:692)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:536)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:483)
       at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:699)
       at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:195)
       at androidx.databinding.DataBindingUtil.setContentView(DataBindingUtil.java:303)
       at androidx.databinding.DataBindingUtil.setContentView(DataBindingUtil.java:284)
       at com.talkhome.onboarding.VerifyPhoneNumberActivity.onCreate(VerifyPhoneNumberActivity.kt:53)
       at android.app.Activity.performCreate(Activity.java:8085)
       at android.app.Activity.performCreate(Activity.java:8073)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1320)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3870)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4076)
       at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:91)
       at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:149)
       at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:103)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2473)
       at android.os.Handler.dispatchMessage(Handler.java:110)
       at android.os.Looper.loop(Looper.java:219)
       at android.app.ActivityThread.main(ActivityThread.java:8349)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1055)

ImageView,其中通货膨胀失败:

<androidx.appcompat.widget.AppCompatImageView
            android:id="@+id/img"
            app:layout_constraintHeight_percent="0.35"
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/guide_line"
            app:srcCompat="@drawable/mobileverification" />

哪里src png 图像在这里具有所有分辨率

知道什么可能会失败吗?

My app runs on every API level, but failing to load on some specific devices sometime.
this time it's failing to find resources which are already there on a HUAWEI device, with device details as follow:

Build.DEVICE : HWJNY 
Build.FINGERPRINT : HUAWEI/JNY-LX1/HWJNY:10/HUAWEIJNY-L21/10.1.0.388C432:user/release-keys 
Build.HARDWARE : kirin810 
Build.PRODUCT : JNY-LX1 
Location : RO 
Brand:HUAWEI
Model:JNY-LX1
Orientation: Portrait
RAM free: 1.57 GB
Disk free: 103.26 GB
Operating system
Version:Android 10
Orientation: Portrait
Rooted:No

Stacktrace:

Non-fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.package/com.package.onboarding.VerifyPhoneNumberActivity}: android.view.InflateException: Binary XML file line #49 in com.package:layout/activity_verify_phone_number_new: Binary XML file line #49 in com.package:layout/activity_verify_phone_number_new: Error inflating class androidx.appcompat.widget.AppCompatImageView
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3897)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4076)
       at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:91)
       at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:149)
       at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:103)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2473)
       at android.os.Handler.dispatchMessage(Handler.java:110)
       at android.os.Looper.loop(Looper.java:219)
       at android.app.ActivityThread.main(ActivityThread.java:8349)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1055)

more to stacktrace:

Caused by android.content.res.Resources$NotFoundException: Resource ID #0x7f080271
       at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:328)
       at android.content.res.Resources.getValue(Resources.java:1468)
       at androidx.appcompat.widget.ResourceManagerInternal.createDrawableIfNeeded(ResourceManagerInternal.java:179)
       at androidx.appcompat.widget.ResourceManagerInternal.getDrawable(ResourceManagerInternal.java:144)
       at androidx.appcompat.widget.ResourceManagerInternal.getDrawable(ResourceManagerInternal.java:135)
       at androidx.appcompat.content.res.AppCompatResources.getDrawable(AppCompatResources.java:104)
       at androidx.appcompat.widget.AppCompatImageHelper.loadFromAttributes(AppCompatImageHelper.java:63)
       at androidx.appcompat.widget.AppCompatImageView.<init>(AppCompatImageView.java:82)
       at androidx.appcompat.widget.AppCompatImageView.<init>(AppCompatImageView.java:69)
       at java.lang.reflect.Constructor.newInstance0(Constructor.java)
       at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
       at android.view.LayoutInflater.createView(LayoutInflater.java:864)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1016)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:971)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:1133)
       at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1094)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:692)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:536)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:483)
       at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:699)
       at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:195)
       at androidx.databinding.DataBindingUtil.setContentView(DataBindingUtil.java:303)
       at androidx.databinding.DataBindingUtil.setContentView(DataBindingUtil.java:284)
       at com.talkhome.onboarding.VerifyPhoneNumberActivity.onCreate(VerifyPhoneNumberActivity.kt:53)
       at android.app.Activity.performCreate(Activity.java:8085)
       at android.app.Activity.performCreate(Activity.java:8073)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1320)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3870)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4076)
       at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:91)
       at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:149)
       at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:103)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2473)
       at android.os.Handler.dispatchMessage(Handler.java:110)
       at android.os.Looper.loop(Looper.java:219)
       at android.app.ActivityThread.main(ActivityThread.java:8349)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1055)

ImageView where inflation is failing:

<androidx.appcompat.widget.AppCompatImageView
            android:id="@+id/img"
            app:layout_constraintHeight_percent="0.35"
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/guide_line"
            app:srcCompat="@drawable/mobileverification" />

Where the src png images are here with all resolutions

Any idea what could be failing it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文