Search code examples
androidandroid-gradle-pluginandroid-multiple-apk

Different APKs for phone and tablet


I have a large number of drawables in my app. If I use the same apk for both phones and tablets the apk size would be too large. Hence I am trying to create two different apks - one for phones and one for tablets. I am doing this on android studio in the gradle file. I have created two different flavors 'phone' and 'tablet' for the same.

I want to include only the drawable folder for the flavor 'phone' and I want to include the folders drawable-sw600dp and drawable-sw720dp for the flavor 'tablet'. How do I achieve this?


Solution

  • I want to include only the drawable folder for the flavor 'phone' and I want to include the folders drawable-sw600dp and drawable-sw720dp for the flavor 'tablet'. How do I achieve this?

    Use the flavor-specific source directories.

    Assuming you haven't modified the default folder structure, move the drawable resource folders you want to variate from src/main/res to src/flavorname/res.

    Note that it makes sense to have the default res/drawable for each variant, so consider naming one of your tablet configurations without the qualifier.