Skip to content

Bundletool install-apks command only installs partial set of APKs if device-spec.json does not match device spec. #57

@Toubap

Description

@Toubap

Describe the bug

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. I got more than 20 crashes whereas the app is just in open beta.

Of course I couldn't reproduce at the beginning then I made many attempts with bundletool.
I figured out that generating an apk from the bundle with a lower density could reproduce the crash, I mean the exact same stackstrace.

I don't known if this is a real issue or a misunderstanding.

Bundletool version(s) affected

Version: tested with 0.8.0 and 0.9.0

Stacktrace

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)

To Reproduce

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.

I created another sample project with the same base configuration (AndroidX, api 17 to 28...) to reproduce this behavior : Sample project
It includes the project, an appbundle file and the specs.json file

The command lines I used :

  • java -jar bundletool-all-0.9.0.jar build-apks --device-spec=specs.json --bundle=app.aab --output=testapk.apks

  • java -jar bundletool-all-0.9.0.jar install-apks --apks=testapk.apks

Expected behavior

Not to crash I guess

Known workaround

  • Disable density splitting
  • Do not use AppBundle

Environment:
Android

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions