Titanium JIRA Archive
Appcelerator Community (AC)

[AC-2960] Android: remote images not loading as cache folder does not appear to exist

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionInvalid
Resolution Date2011-12-15T13:36:11.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsandroid, cache, defect, imageView, remote
Reporterkosso
AssigneeShak Hossain
Created2011-12-15T13:03:47.000+0000
Updated2016-03-08T07:47:57.000+0000

Description

I've seen this crop up now and again: basically I have a table with images being loaded in the rows. Initially this was working. But when I've updated the app and tweaked some unrelated scripts, then go to totally remove the app from the device then re-install it, the remote images fail to load. It appears the remote image cache folder is non-existent (any more):
/TiDownloadManager( 4451): (pool-2-thread-1) [65,7571] Exception downloading http://i.ytimg.com/vi/tCdUiL4FpLI/2.jpg
E/TiDownloadManager( 4451): java.io.FileNotFoundException: /mnt/sdcard/Android/data/com.amazingmedia.radio1/cache/_tmp/remote-cache/771b3e39cf992ed3f545043f43fff914ce8071ef.hdr (No such file or directory)
E/TiDownloadManager( 4451): 	at org.apache.harmony.luni.platform.OSFileSystem.open(Native Method)
E/TiDownloadManager( 4451): 	at dalvik.system.BlockGuard$WrappedFileSystem.open(BlockGuard.java:232)
E/TiDownloadManager( 4451): 	at java.io.FileOutputStream.<init>(FileOutputStream.java:94)
E/TiDownloadManager( 4451): 	at java.io.FileOutputStream.<init>(FileOutputStream.java:66)
E/TiDownloadManager( 4451): 	at java.io.FileWriter.<init>(FileWriter.java:42)
E/TiDownloadManager( 4451): 	at org.appcelerator.titanium.util.TiResponseCache.put(TiResponseCache.java:374)
E/TiDownloadManager( 4451): 	at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.maybeCache(HttpURLConnectionImpl.java:331)
E/TiDownloadManager( 4451): 	at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.retrieveResponse(HttpURLConnectionImpl.java:1043)
E/TiDownloadManager( 4451): 	at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:512)
E/TiDownloadManager( 4451): 	at java.net.URL.openStream(URL.java:645)
E/TiDownloadManager( 4451): 	at org.appcelerator.titanium.util.TiDownloadManager$DownloadJob.run(TiDownloadManager.java:157)
E/TiDownloadManager( 4451): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
E/TiDownloadManager( 4451): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
E/TiDownloadManager( 4451): 	at java.lang.Thread.run(Thread.java:1019)
E/TiDownloadManager( 4451): (pool-2-thread-2) [48,7720] Exception downloading http://i.ytimg.com/vi/jk_Kmlj-U7A/2.jpg
E/TiDownloadManager( 4451): java.io.FileNotFoundException: /mnt/sdcard/Android/data/com.amazingmedia.radio1/cache/_tmp/remote-cache/aa30b9ef9b18afe0bb37ec514c85b8ec04a8f8c2.hdr (No such file or directory)
E/TiDownloadManager( 4451): 	at org.apache.harmony.luni.platform.OSFileSystem.open(Native Method)
E/TiDownloadManager( 4451): 	at dalvik.system.BlockGuard$WrappedFileSystem.open(BlockGuard.java:232)
..etc... The only way I seem to get this to work is to change the app id and rebuild and install (effectively a new app) - this is not possible, since my app is already in the Android Market, so the app id will need to be the same (com.amazingmedia.radio1) when I do the update. (Only the version code/number changes) So, for some reason, it appears that the remote image cache folder is not being created. If I (try to) navigate in the file manager on the device to /mnt/sdcard/Android/data/com.amazingmedia.radio1 it does not exist.

Comments

  1. kosso 2011-12-15

    It now appears that clearing out the build folder and forcing a fresh rebuild actually fixed this. Very odd. I'm sure I'd tried that first! Sorry! Feel free to make as closed.
  2. Paul Dowsett 2011-12-15

    Hi Kosso I have improved the ticket as much as I can, to bring it in line with the [JIRA Ticket Checklist](https://wiki.appcelerator.org/display/guides/How+to+Submit+a+Bug+Report#HowtoSubmitaBugReport-JIRATicketChecklist), but there is still some missing information which is preventing me from moving it to TIMOB. Would you mind providing more details of the environment and your code (at least relating to the table)? Also, please remember to use the markup syntax provided, as it makes the ticket easier to understand. If you can do so soon, I can move it across tonight. Many thanks Paul
  3. Paul Dowsett 2011-12-15

    Kosso, do you really mean that /mnt/sdcard/Android/data/com.amazingmedia.radio1 does not exist, or that /mnt/sdcard/Android/data/com.amazingmedia.radio/cache/ does not exist?
  4. kosso 2011-12-15

    See my first comment. It seems that forcing a rebuild by deleting the contents of build/android/* fixed this. I thought I'd tried this first. Then did it after submitting this ticket, after spending a few hours trying all sorts of solutions. That did it! ;) Sorry.
  5. Paul Dowsett 2011-12-15

    Don't worry - you can always reopen this if it does in fact seem to be a bug. Thanks for the update, mate! :)
  6. Jorge Carro 2012-09-11

    I have the same problem and I resolved adding the permission WRITE_EXTERNAL_STORAGE to the AndroidManifest.xml.
  7. Mostafizur Rahman 2013-12-28

    Hello, We tested this issue recently and we were unable to reproduce this error wi TiSDK 3.2.0GA. Please check our test code and let us know if you notice any different results.

    Test Environment

    MAC OSX Version 10.9, Titanium SDK 3.2.0.GA Android SDK: 2.3.3 Android Device 4.2.2

    Test Code

        var win = Titanium.UI.createWindow({
       	backgroundColor : '#fff'
       });
       // Create table view row
        
       var table = Ti.UI.createTableView({
       	
       });
        
        
       // Create http client
        
       c = Titanium.Network.createHTTPClient();
       c.setTimeout(10000);
       	
       c.onload = function() {
       		Ti.API.info('IN ONLOAD ');
       			xml=this.responseXML.documentElement;
       			doc=xml.getElementsByTagName("channel");
       			
       	        for(var a=0;a<doc.length;a++)
       	        {
       				var row=Ti.UI.createTableViewRow({
       					layout:'horizontal',
       			});
       			 var view=Ti.UI.createView({
       			 	layout:'vertical',
       			 	width:170,
       			 	height:Ti.UI.SIZE
       			 });
       				
       				
       				// Create an ImageView.
       				var thumbnail = Ti.UI.createImageView({
       					image : doc.item(a).getElementsByTagName("media:thumbnail").item(0).getAttribute("url"),
       					width : 300,
       					height : 300,
       					top:100
       			
       				});
       		
       				// Add to the parent view.
       				row.add(thumbnail);
       				row.add(view);
       				
       				table.appendRow(row);
       			}
       }
       c.ondatastream = function(e) {
        
       };
       c.onerror = function(e) {
       	Ti.API.info('XHR Error ' + e.error);
       };
        
       // open the client
        
       c.open('GET','https://picasaweb.google.com/data/feed/base/user/103230497594919445319/albumid/5877428846435928449?alt=rss&kind=photo&hl=en_US');
        
       // send the data
       c.send();
        
        
       win.add(table);
       win.open();
       
  8. Shak Hossain 2013-12-30

    Closing this since the issue is not reproducible with our latest versions of the TISDK. A functional sample has been posted for your reference.

JSON Source