我的Android App 支持7.0及以上版本但不支持6和5

Posted

技术标签:

【中文标题】我的Android App 支持7.0及以上版本但不支持6和5【英文标题】:My Android App support in version 7.0 and upper version but not support version 6 and 5 【发布时间】:2020-03-27 17:13:03 【问题描述】:

其实我不知道是什么问题。我试过但不明白确切的问题!

compileSdkVersion 28,
minSdkVersion 21,
targetSdkVersion 28.

此问题仅在 android 版本 6 和 5 中出现。但我的应用在 android 7.0 及更高版本中正常运行。

这里是 Logcat 错误消息

12-03 09:23:44.932 6025-6025/? I/art: Not late-enabling -Xcheck:jni (already on) 12-03 09:23:45.029 6025-6025/io.destreza.erp_dashboard W/System: ClassLoader referenced unknown path: /data/app/io.destreza.erp_dashboard-1/lib/x86 12-03 09:23:45.075 6025-6025/io.destreza.erp_dashboard D/FirebaseApp: com.google.firebase.auth.FirebaseAuth is not linked. Skipping initialization. 12-03 09:23:45.076 6025-6025/io.destreza.erp_dashboard D/FirebaseApp: com.google.firebase.crash.FirebaseCrash is not linked. Skipping initialization. 12-03 09:23:45.076 6025-6025/io.destreza.erp_dashboard D/FirebaseApp: com.google.android.gms.measurement.AppMeasurement is not linked. Skipping initialization. 12-03 09:23:45.076 6025-6025/io.destreza.erp_dashboard I/FirebaseInitProvider: FirebaseApp initialization successful 12-03 09:23:45.116 6025-6025/io.destreza.erp_dashboard W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable 12-03 09:23:45.149 6025-6025/io.destreza.erp_dashboard I/art: Rejecting re-init on previously-failed class java.lang.Class<android.support.v4.view.ViewCompat$OnUnhandledKeyEventListenerWrapper> 12-03 09:23:45.149 6025-6025/io.destreza.erp_dashboard I/art: Rejecting re-init on previously-failed class java.lang.Class<android.support.v4.view.ViewCompat$OnUnhandledKeyEventListenerWrapper> 12-03 09:23:45.194 6025-6025/io.destreza.erp_dashboard W/ResourceType: Failure getting entry for 0x7f07009e (t=6 e=158) (error -75) 12-03 09:23:45.195 6025-6025/io.destreza.erp_dashboard D/AndroidRuntime: Shutting down VM 12-03 09:23:45.196 6025-6025/io.destreza.erp_dashboard E/AndroidRuntime: FATAL EXCEPTION: main
    Process: io.destreza.erp_dashboard, PID: 6025
    java.lang.RuntimeException: Unable to start activity ComponentInfoio.destreza.erp_dashboard/io.destreza.erp_dashboard.activities.main.MainActivity: android.view.InflateException: Binary XML file line #53: Binary XML file line #53: Error inflating class ImageView
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
        at android.app.ActivityThread.-wrap11(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:148)
        at android.app.ActivityThread.main(ActivityThread.java:5417)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
     Caused by: android.view.InflateException: Binary XML file line #53: Binary XML file line #53: Error inflating class ImageView
        at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
        at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
        at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
        at io.destreza.erp_dashboard.activities.main.MainActivity.onCreate(MainActivity.java:115)
        at android.app.Activity.performCreate(Activity.java:6237)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
        at android.app.ActivityThread.-wrap11(ActivityThread.java) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:148) 
        at android.app.ActivityThread.main(ActivityThread.java:5417) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
     Caused by: android.view.InflateException: Binary XML file line #53: Error inflating class ImageView
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:782)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:838)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:838)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
        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 android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469) 
        at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
        at io.destreza.erp_dashboard.activities.main.MainActivity.onCreate(MainActivity.java:115) 
        at android.app.Activity.performCreate(Activity.java:6237) 
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) 
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) 
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
        at android.app.ActivityThread.-wrap11(ActivityThread.java) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:148) 
        at android.app.ActivityThread.main(ActivityThread.java:5417) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
     Caused by: android.content.res.Resources$NotFoundException: Resource "io.destreza.erp_dashboard:drawable/logo_main" (7f07009e) is not a Drawable (color or path): TypedValuet=0x1/d=0x7f07009e a=-1 r=0x7f07009e
        at android.content.res.Resources.loadDrawableForCookie(Resources.java:2602)
        at android.content.res.Resources.loadDrawable(Resources.java:2540)
        at android.content.res.TypedArray.getDrawable(TypedArray.java:870)
        at android.view.View.<init>(View.java:3948)
        at android.widget.ImageView.<init>(ImageView.java:145)
        at android.widget.ImageView.<init>(ImageView.java:140)
        at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:72)
        at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:68)
        at android.support.v7.app.AppCompatViewInflater.createImageView(AppCompatViewInflater.java:182)
        at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:106)
        at android.support.v7.app.AppCompatDelegateImpl.createView(AppCompatDelegateImpl.java:1266)
        at android.support.v7.app.AppCompatDelegateImpl.onCreateView(AppCompatDelegateImpl.java:1316)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:746)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) 
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:835) 
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) 
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:838) 
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) 
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:838) 
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) 
        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 android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469) 
        at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
        at io.destreza.erp_dashboard.activities.main.MainActivity.onCreate(MainActivity.java:115) 
        at android.app.Activity.performCreate(Activity.java:6237) 
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) 
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) 
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
        at android.app.ActivityThread.-wrap11(ActivityThread.java) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:148) 
        at android.app.ActivityThread.main(ActivityThread.java:5417) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)  12-03 09:24:15.098 6025-6044/io.destreza.erp_dashboard E/FirebaseInstanceId: Token retrieval failed: SERVICE_NOT_AVAILABLE 12-03 09:25:15.188 6025-6044/io.destreza.erp_dashboard E/FirebaseInstanceId: Token retrieval failed: SERVICE_NOT_AVAILABLE 12-03 09:26:45.255 6025-6044/io.destreza.erp_dashboard E/FirebaseInstanceId: Token retrieval failed: SERVICE_NOT_AVAILABLE 12-03 09:28:45.594 6025-6025/io.destreza.erp_dashboard I/Process: Sending signal. PID: 6025 SIG: 9 [app has been stoped!][1]

Screenshot-The app has been stopped!

【问题讨论】:

【参考方案1】:

检查您的资源和其他人,当他们在应用程序将无法运行的更高版本文件夹中时。

【讨论】:

【参考方案2】:
FATAL EXCEPTION: main Process: io.destreza.erp_dashboard, PID: 6025 java.lang.RuntimeException: Unable to start activity ComponentInfoio.destreza.erp_dashboard/io.destreza.erp_dashboard.activities.main.MainActivity: android.view.InflateException: Binary XML file line #53: Binary XML file line #53: Error inflating class ImageView at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416) at

这就是问题在于尝试查找是否可以找到资源。如果它被找到但它是矢量图像,那么它可能会崩溃,因为某些矢量图像在旧的 android 版本中无法正常工作,也许可以尝试用 png 图像更改它

【讨论】:

我终于解决了!基本上这不是图像类型问题。我用 android:src="@drawable/logo_main" 代替 android:background="@drawable/logo_main" 谢谢 Nikhil

以上是关于我的Android App 支持7.0及以上版本但不支持6和5的主要内容,如果未能解决你的问题,请参考以下文章

安卓7.0及以上系统如何抓取Https的包

安卓7.0及以上版本抓包https失败解决方法

关于 Android 7.0 适配中 FileProvider 部分的总结

我们来一探究竟 Android 7.0 适配中 FileProvider 部分

如何让Xcode8 支持ios7及以下的版本

Android 7.0 以上 Charles 和 Fiddler 无法抓取 HTTPS 包的解决方式