Android device uses resources from different density sets in debug and signed APK












8















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?










share|improve this question























  • It looks like I should be defining my custom dimensions in height specific dimension files like values-h800/dimens.xml etc. But my question is still valid.

    – Amarghosh
    Dec 29 '18 at 0:15











  • can you post outputs of Analyze apks, It is present in Build | Analyze apk , then select the apks, Repeat same steps on the apks on which you are getting different output. I checked on a sample app, worked fine on my phone, got same results everytime, with each method.

    – nkalra0123
    Jan 3 at 6:37











  • do you have different flavors ??

    – Assem Mahrous
    Jan 6 at 10:38











  • @AssemMahrous nope.

    – Amarghosh
    Jan 7 at 22:48











  • @Amarghosh Does it happen on other android devices (none samsung mobiles) too?

    – Merka
    Jan 8 at 13:11
















8















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?










share|improve this question























  • It looks like I should be defining my custom dimensions in height specific dimension files like values-h800/dimens.xml etc. But my question is still valid.

    – Amarghosh
    Dec 29 '18 at 0:15











  • can you post outputs of Analyze apks, It is present in Build | Analyze apk , then select the apks, Repeat same steps on the apks on which you are getting different output. I checked on a sample app, worked fine on my phone, got same results everytime, with each method.

    – nkalra0123
    Jan 3 at 6:37











  • do you have different flavors ??

    – Assem Mahrous
    Jan 6 at 10:38











  • @AssemMahrous nope.

    – Amarghosh
    Jan 7 at 22:48











  • @Amarghosh Does it happen on other android devices (none samsung mobiles) too?

    – Merka
    Jan 8 at 13:11














8












8








8


3






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?










share|improve this question














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?







android dpi screen-density pixel-density






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 29 '18 at 0:13









AmarghoshAmarghosh

49k1078112




49k1078112













  • It looks like I should be defining my custom dimensions in height specific dimension files like values-h800/dimens.xml etc. But my question is still valid.

    – Amarghosh
    Dec 29 '18 at 0:15











  • can you post outputs of Analyze apks, It is present in Build | Analyze apk , then select the apks, Repeat same steps on the apks on which you are getting different output. I checked on a sample app, worked fine on my phone, got same results everytime, with each method.

    – nkalra0123
    Jan 3 at 6:37











  • do you have different flavors ??

    – Assem Mahrous
    Jan 6 at 10:38











  • @AssemMahrous nope.

    – Amarghosh
    Jan 7 at 22:48











  • @Amarghosh Does it happen on other android devices (none samsung mobiles) too?

    – Merka
    Jan 8 at 13:11



















  • It looks like I should be defining my custom dimensions in height specific dimension files like values-h800/dimens.xml etc. But my question is still valid.

    – Amarghosh
    Dec 29 '18 at 0:15











  • can you post outputs of Analyze apks, It is present in Build | Analyze apk , then select the apks, Repeat same steps on the apks on which you are getting different output. I checked on a sample app, worked fine on my phone, got same results everytime, with each method.

    – nkalra0123
    Jan 3 at 6:37











  • do you have different flavors ??

    – Assem Mahrous
    Jan 6 at 10:38











  • @AssemMahrous nope.

    – Amarghosh
    Jan 7 at 22:48











  • @Amarghosh Does it happen on other android devices (none samsung mobiles) too?

    – Merka
    Jan 8 at 13:11

















It looks like I should be defining my custom dimensions in height specific dimension files like values-h800/dimens.xml etc. But my question is still valid.

– Amarghosh
Dec 29 '18 at 0:15





It looks like I should be defining my custom dimensions in height specific dimension files like values-h800/dimens.xml etc. But my question is still valid.

– Amarghosh
Dec 29 '18 at 0:15













can you post outputs of Analyze apks, It is present in Build | Analyze apk , then select the apks, Repeat same steps on the apks on which you are getting different output. I checked on a sample app, worked fine on my phone, got same results everytime, with each method.

– nkalra0123
Jan 3 at 6:37





can you post outputs of Analyze apks, It is present in Build | Analyze apk , then select the apks, Repeat same steps on the apks on which you are getting different output. I checked on a sample app, worked fine on my phone, got same results everytime, with each method.

– nkalra0123
Jan 3 at 6:37













do you have different flavors ??

– Assem Mahrous
Jan 6 at 10:38





do you have different flavors ??

– Assem Mahrous
Jan 6 at 10:38













@AssemMahrous nope.

– Amarghosh
Jan 7 at 22:48





@AssemMahrous nope.

– Amarghosh
Jan 7 at 22:48













@Amarghosh Does it happen on other android devices (none samsung mobiles) too?

– Merka
Jan 8 at 13:11





@Amarghosh Does it happen on other android devices (none samsung mobiles) too?

– Merka
Jan 8 at 13:11












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53965629%2fandroid-device-uses-resources-from-different-density-sets-in-debug-and-signed-ap%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53965629%2fandroid-device-uses-resources-from-different-density-sets-in-debug-and-signed-ap%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

MongoDB - Not Authorized To Execute Command

How to fix TextFormField cause rebuild widget in Flutter

Npm cannot find a required file even through it is in the searched directory