10

I noticed that my app shows slightly different layout on the same device depending on whether I am running the debug APK or the signed release APK. After much head scratching, I have isolated the problem to device density specific resource values. The device uses dimensions from values-xxhdpi/dimens.xml when I run the app in debug mode, and it uses dimensions from values-xxxhdpi/dimens.xml when I run the signed APK. The device in question is Samsung Galaxy S7 running Android 7.0

Just to confirm this, I created a new empty project with just a hello world string in it. I defined different values for the string in values/strings.xml, values-xxhdpi/strings.xml and values-xxxhdpi/strings.xml. Here are the results.

  • Debug apk shows xxhdpi string. Works as expected.
  • Running the release apk from android studio (by specifying a signing config in the gradle file) shows xxhdpi string. Works as expected.
  • Generate a signed apk by selecting Build | Generate Signed APK and run it. This time the app shows xxxhdpi string. Why ?!

Why is this happening? Why is android selecting xxhdpi resources in debug mode and xxxhdpi resources in a signed APK?

Amarghosh
  • 58,710
  • 11
  • 92
  • 121

0 Answers0