通过使用 Android 的新 Android App Bundle,我在 2 个 Google Play 商店应用中收到 Resource Not Found
错误.
By using Android's new Android App Bundle, I have received a Resource Not Found
error in 2 of my Google Play Store apps.
以下是其中一个应用的 fabric 堆栈跟踪:
Here is the stacktrace from fabric for one of the apps:
Unable to start activity ComponentInfo{/com.Lastyear.MainActivity}: android.content.res.Resources$NotFoundException: File res/drawable/abc_item_background_holo_dark.xml from drawable resource ID #0x7f08002c
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2377)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2429)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1342)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5363)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:828)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:644)
at dalvik.system.NativeStart.main(NativeStart.java)
build.gradle
依赖:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:customtabs:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.android.support:palette-v7:27.1.1'
implementation 'com.afollestad.material-dialogs:core:0.9.6.0'
implementation 'com.jakewharton:butterknife:8.8.1'
implementation 'com.github.bumptech.glide:glide:3.7.0'
implementation 'com.android.support:design:27.1.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
implementation 'com.github.hotchemi:android-rate:1.0.1'
implementation 'com.hannesdorfmann.smoothprogressbar:library:1.0.0'
implementation 'com.android.support:palette-v7:27.1.1'
implementation 'com.google.android.gms:play-services-ads:15.0.1'
implementation 'com.muddzdev:styleabletoast:1.0.9'
implementation 'com.github.GrenderG:Toasty:1.2.5'
implementation 'com.hannesdorfmann.smoothprogressbar:library:1.0.0'
implementation 'com.wang.avi:library:2.1.3'
implementation 'com.github.medyo:fancybuttons:1.8.4'
implementation 'com.irozon.sneaker:sneaker:1.0.1'
implementation 'com.sdsmdg.tastytoast:tastytoast:0.1.1'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.github.barteksc:android-pdf-viewer:2.8.2'
implementation 'com.getkeepsafe.taptargetview:taptargetview:1.11.0'
implementation('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
transitive = true;
}
implementation 'petrov.kristiyan:colorpicker-library:1.1.8'}
还有一件事,它只发生在 Android 4 操作系统上,而不是在较新版本的 Android 上.我发现其他应用程序也有同样的 Resource Not Found
问题,这在使用 Android 的 app bundle 之前是不存在的.库或代码是否有问题,或者是因为 Android 的 app bundle 的 beta 版本?
One more thing, it is happening only on Android 4 operating system, not on newer versions of Android. I have found that other apps are having the same problem of Resource Not Found
, which was not existing before using Android's app bundle. Is there some problem in the library or code or it is because of the beta version of Android's app bundle?
我还发现了导致它崩溃的可绘制资源:-
I have also found the resource drawable due to which it crashes:-
我认为这个问题也与这个问题有关:Resource Not Found error res/drawable/abc_switch_thumb_material.xml after added SwitchCompat in Android App Bundle
I think this question is also related to this one: Resource Not Found error res/drawable/abc_switch_thumb_material.xml after adding SwitchCompat in Android App Bundle
这几乎可以肯定是用户通过 P2P 共享程序共享(旁加载)应用程序,或者将 APK 上传到网络,然后其他用户从网络.
This is almost certainly users sharing (sideloading) the app, either via P2P sharing programs, or uploading the APK to the web then other users downloading and installing from the web.
人们习惯于处理非 Android App Bundle 应用程序只是转移和共享主 APK.但是您的 App bundle 应用程序有很多用于资源之类的拆分 APK",这就是节省大小的方式.您可以在帮助页面上阅读有关此过程的所有信息.如果用户在安装主 APK 时未安装正确的拆分 APK,则应用第一次尝试加载资源时会发生找不到资源"崩溃.
People used to dealing with non Android App Bundle apps just transfer and share the main APK. But your App bundle app has lots of "split APKs" for things like the resources, that is how the size saving happens. You can read all about this process on the help page. If a user installs the main APK without installing the right split APKs, then a "Resources Not found" crash will occur the first time the app tries to load a resource.
如果您想支持用户侧载您的应用和仅主 APK,您可以尝试检测这种情况并向用户显示一条消息(不使用任何资源),上面写着请从 Google Play 安装".或者您可以决定不支持以这种方式共享 APK 的用户.
If you want to support users sideloading your app and just the main APK you could try to detect this situation and display a message to the user (without using any resources) that says "Please install from Google Play". Or you could just decide you aren't going to support users who share APKs in this way.
我怀疑从长远来看,网站和 P2P 共享程序会更好地正确共享此类 APK,所以我不会花太长时间担心它.
I suspect in the long run the websites and P2P sharing programs will get better at sharing such APKs properly, so I wouldn't spend too long worrying about it.
如果您发现这种情况在较低的 Android 版本上发生得更频繁,这可能不是由于较低的 Android 版本中的错误.相反,这可能是因为在用户通常使用 P2P 共享应用程序的国家(例如印度),用户也更有可能使用旧版手机.
If you see this happening far more frequently on lower Android versions, this isn't probably due to a bug in lower Android versions. Instead, it is probably because in countries where users commonly P2P share apps (eg India) users also are far more likely to be on older version phones.
这篇关于Android App Bundle 在 Android 应用中引入 Resource Not found crash的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!