Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-12430] Android images at multiple resolutions are selected in wrong order

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionNeeds more info
Resolution Date2013-02-02T01:52:26.000+0000
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
Labelsandroid, image, resolution
ReporterEsben Maaløe
AssigneeEduardo Gomez
Created2012-08-14T09:00:10.000+0000
Updated2017-03-16T20:41:40.000+0000

Description

If you have the following images: Resources/images/test.png Resources/android/images/test.png Resources/android/images/res-notlong-port-mdpi/test.png and somewhere in your code you assign: backgroundImage : '/images/test.png' and run it on a res-notlong-port-mdpi device (the emulator at 320x480 is such a device) it would be natural if: DESIRED BEHAVIOUR ================ The image selected was the one from the specific platform and resolution (Resources/android/images/res-notlong-port-mdpi/test.png) If no platform/resolution specific image is found - look for a platform specific: (Resources/android/images/test.png) If no platform specific image is found, look for the generic image (Resources/images/test.png) Instead you get this: ACTUAL BEHAVIOUR ================ Is there a generic image (Resources/images/test.png) ? If so use it, and abort further search! CONCLUSION ========== The system ends up preferring images that was NOT meant for the particular device, even though better images are present, meaning you have to code around it and have an elaborate "which platform and resolution" logic in the appcode. It is the exact same reversal of logic with 9-patch images. if you have test.png and test.9.png - Ti will always use test.png.

Comments

  1. Davide Cassenti 2012-09-11

    I don't seem to be able to reproduce the issue. Which version of Studio are you using? I tested with Studio 2.1.2 and SDK 2.1.2 and looked to be correct. Let me know! Thanks.
  2. Esben Maaløe 2012-09-11

    Hi Davide, Dang, I forgot to include that info, sry. It must have been the 2.1.1/2.1.1 combo, but I'm not sure (you can check the date of my submission) this test is on 2.1.2/2.1.2 UBUNTU Linux Something seems to have changed. As far as I can see, imageViews do it right in 2.1.2, but the buttonview does not! (urging you to test imageViews anyway, I did not test in depth) I've made at test-case here: http://dl.dropbox.com/u/776614/imagetest.zip Here's the test when I run it: Run in emulator Android HVGA ==================== Two buttons with diff. text is shown. The text is graphical, not a result of the title attrib. Desired result: top button: "9p resolution" bottom button: "Test resolution" 1. Run as is: result: top : "Not button.9.png" FAIL bottom : "Test Android" FAIL 2. delete (rename) '/images/button.png' and '/images/test.png' clean project run again result top : "9p resolution" SUCCESS bottom text : "Test Android" FAIL 3. delete (rename) '/images/android/res-notlong-port-mdpi/button.9.png' and '/images/android/test.png' clean project run again desired result: top : "9p android" bottom text : "Test Resolution" result top : "9p resolution" SUCCESS bottom text : "Test Android" SUCCESS
  3. Esben Maaløe 2012-09-11

    Dang - that very last line should've been bottom text : "Test Resolution" SUCCESS
  4. Esben Maaløe 2012-09-11

    Btw - test 1 "run as is" is the one that should be successful on both images.
  5. Eduardo Gomez 2013-01-28

    Hello Esben, I attempted to run the sample attached. However the 9 patch image is malformed.

    i.e. console logs

       [ERROR] ERROR: 9-patch image res/drawable-notlong-port-mdpi/button_1aab581dd3.9.png malformed.
       [ERROR]        Ticks in transparent frame must be black.
       [ERROR]        Found at pixel #84 along bottom edge.
       [ERROR] ERROR: Failure processing PNG image res/drawable-notlong-port-mdpi/button_1aab581dd3.9.png
       [DEBUG] creating unsigned apk: /Users/egomez/Documents/Titanium Studio Workspace/TIMOB-12430/build/android/bin/app-unsigned.apk
       [ERROR] Exception occured while building Android project:
       [ERROR] Traceback (most recent call last):
       [ERROR]   File "/Library/Application Support/Titanium/mobilesdk/osx/2.1.2.GA/android/builder.py", line 2243, in <module>
       [ERROR]     s.build_and_run(True, avd_id, device_args=device_args)
       [ERROR]   File "/Library/Application Support/Titanium/mobilesdk/osx/2.1.2.GA/android/builder.py", line 2068, in build_and_run
       [ERROR]     launched, launch_failed = self.package_and_deploy()
       [ERROR]   File "/Library/Application Support/Titanium/mobilesdk/osx/2.1.2.GA/android/builder.py", line 1585, in package_and_deploy
       [ERROR]     unsigned_apk = self.create_unsigned_apk(ap_)
       [ERROR]   File "/Library/Application Support/Titanium/mobilesdk/osx/2.1.2.GA/android/builder.py", line 1447, in create_unsigned_apk
       [ERROR]     resources_zip = zipfile.ZipFile(resources_zip_file)
       [ERROR]   File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/zipfile.py", line 699, in __init__
       [ERROR]     self.fp = open(file, modeDict[mode])
       
    Would it work from another working sample in order to replicate what you are seeing?
  6. Eduardo Gomez 2013-02-02

    Closing due to inactivity. I'd reopen when resources are available in order to replicate what you are seeing.
  7. Lee Morris 2017-03-16

    Closing ticket as the information that was requested was never provided.

JSON Source