1

After integrating App-Bundle into my professional app I faced many issues through Crashlytics about the first screen of the app when inflating an ImageView.

This is the ResourceNotFoundException.

Caused by: android.view.InflateException: Binary XML file line #48: Binary XML file line #48: Error inflating class ImageView
Caused by: android.view.InflateException: Binary XML file line #48: Error inflating class ImageView
Caused by: android.content.res.Resources$NotFoundException: Drawable (missing name) with resource ID #0x7f08009d
Caused by: android.content.res.Resources$NotFoundException: Unable to find resource ID #0x7f08009d
    at android.content.res.ResourcesImpl.getResourceName(ResourcesImpl.java:242)
    at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:739)
    at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:609)
    at android.content.res.Resources.loadDrawable(Resources.java:885)
    at android.content.res.TypedArray.getDrawableForDensity(TypedArray.java:953)
    at android.content.res.TypedArray.getDrawable(TypedArray.java:928)
    at android.widget.ImageView.<init>(ImageView.java:188)
    at android.widget.ImageView.<init>(ImageView.java:171)
    at androidx.appcompat.widget.AppCompatImageView.<init>(AppCompatImageView.java:72)
    at androidx.appcompat.widget.AppCompatImageView.<init>(AppCompatImageView.java:68)
    at androidx.appcompat.app.AppCompatViewInflater.createImageView(AppCompatViewInflater.java:187)
    at androidx.appcompat.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:107)
    at androidx.appcompat.app.AppCompatDelegateImpl.createView(AppCompatDelegateImpl.java:1267)
    at androidx.appcompat.app.AppCompatDelegateImpl.onCreateView(AppCompatDelegateImpl.java:1317)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:772)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
    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.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:470)
    at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:141)
    at io.example.SplashScreen.onCreate(SplashScreenActivity.kt:50)
    at android.app.Activity.performCreate(Activity.java:6975)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
    at android.app.ActivityThread.-wrap11(Unknown Source:0)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
    at android.os.Handler.dispatchMessage(Handler.java:105)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6541)

2019-03-11 12:13:52.605 14143-14143/? E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

Of course I couldn't reproduce at the beginning then I made many attempts with bundletool. I've seen similar threads but not digging the issue enough.

I figured out that generating an apk from the bundle with a lower density could reproduce the crash.

With my attempt I extracted Nexus6P specs as following

{
  "supportedAbis": ["x86"],
  "supportedLocales": ["en_US"],
  "screenDensity": 560,
  "sdkVersion": 26
}

Then I changed screenDensity to 320 or even 120 which makes the crash happen. Lookin' deeper at the *.apks generated file we have :

  • base-en.apk
  • base-ldpi.apk
  • base-master.apk

I currently have mdpi/hdpi/xhdpi/xxhdpi/xxxhdpi folders.

I tried adding drawable-ldpi folder but in vain.

I checked in base-ldpi.apk to look after the resource not found, it is well present in the apk.

As a quick fix I can disable density splitting from gradle configuration or even turn off app bundle but I wish for a better ending.

Any idea ? Thank you :)

Toubap
  • 29
  • 7
  • You didn't include the Exception. – Gavin Wright Mar 11 '19 at 12:00
  • Seems like a duplicate of https://stackoverflow.com/questions/50471888/android-app-bundle-introduces-resource-not-found-crash-in-android-app/50604296 – Pierre Mar 11 '19 at 12:16
  • Because the exception explains itself, I edited with related exception. As a I said the other threads do not cover properly the issue. The fact that sideloading plarforms make this crash happen is a thing. Here I want to talk about app bundle especially – Toubap Mar 11 '19 at 12:28
  • What do you mean by "not properly cover"? The other threads explain quite in detail what is happening, I would say: the base APK is sideloaded without the config split APKs. You can reproduce by manually installing only the base-master.apk file extracted from the APK Set archive that bundletool generates. What other information are you looking for? – Pierre Mar 11 '19 at 23:59
  • Then I don't understand why it crashes with this *.apks file. The original density for the Nexus6P was 560, if I switch to 620 it doesn't crash but 120 got the crash. The only solution I have is to disable density splitting, which is not the good way – Toubap Mar 12 '19 at 09:10
  • When you reproduce locally, do you have the same stacktrace? The only way I can help you debug this is if you're able to share with me the App Bundle. You can also do this through the issue tracker of bundletool's GitHub repo if you prefer. If you don't feel comfortable sharing the App Bundle, then at least a project that can reproduce the error. – Pierre Mar 13 '19 at 23:42
  • Yes the same stacktrace, I made another project which reproduces the same behavior. I uploaded it with the appbundle and the specs.json files (https://drive.google.com/open?id=1HQIjcoXy9NQ5P9ZXdJOeZpBAFceJ9zgx). If you consider it as a real issue I will create an issue on github. ps : I tested with 0.8.0 and 0.9.0 versions. thanks – Toubap Mar 14 '19 at 09:53
  • Please file a bug there, yes, it will be easier to track the investigation than in a stackoverflow comment thread :) Thanks! – Pierre Mar 14 '19 at 20:10
  • Ok thank you, I filled an issue – Toubap Mar 15 '19 at 08:59

0 Answers0