32bit stage-packages in 64bit build

Android Studio on 64bit Ubuntu release requires below packages to be installed for the emulator to work
libc6:i386 libncurses5:i386 libstdc++6:i386 lib32z1 libbz2-1.0:i386

We want to ship those packages with only the 64bit snap as they are redundant on 32bit installs.

I get below error while trying to build that snap:

Error downloading stage packages for part 'android-studio': The package 'libc6:i386' was not found.
You may need to add support for this architecture with 'dpkg --add-architecture i386'.

On local systems I can do dpkg --add-architecture i386 but I need a way that work on build.snapcraft as well.

my yaml looks like this https://github.com/om26er/android-studio/blob/emulator-req-fix/snap/snapcraft.yaml

You can try adding a new part:

    plugin: nil
    prepare: |
      dpkg --add-architecture i386
      apt-get update

    after: [enable-i386]

This worked, though one issue now is that my 32bit build fails because lib32z1 is not available on i386. Can I only stage those packages on a specific arch ?

Check my yaml https://github.com/snapcrafters/android-studio/blob/master/snap/snapcraft.yaml#L45

try zlib1g:i386 instead.