Copyfile working on simulator but not on android device

Hello, I’ve been compiling my app for the android platform but run into a problem whereby copying a file from the resources directory into the documents or temporary directory does not work. It simply crashes the app on the phone. It does work fine on the simulator and on iphone devices. I’m using exactly the same code from here to copy the files: http://developer.coronalabs.com/reference/index/filewrite

There’s no error messages at all on the phone the app simply freezes, I know it’s the copy functions as removing them makes it work. I can write to those directories ok just using fwrite, as the html file I’m creating is written fine, it’s just something in the copying for some reason. I’m copying just PNG files.

Thanks in advance! [import]uid: 110859 topic_id: 32111 reply_id: 332111[/import]

Just a quick follow up, it does seem to work when copying text files ok, so maybe just a problem copying PNGs? [import]uid: 110859 topic_id: 32111 reply_id: 127916[/import]

Just a quick follow up, it does seem to work when copying text files ok, so maybe just a problem copying PNGs? [import]uid: 110859 topic_id: 32111 reply_id: 127916[/import]

I’m also getting the same problem copying JPGs, has anyone got any ideas to solve this? [import]uid: 110859 topic_id: 32111 reply_id: 128146[/import]

Supposedly there’s a bug case already submitted for this (case number 17598 although I can’t actually see it in the list…). I’ve realised the problem is actually with system.pathforfile whereby it isn’t returning the path problem when referencing an image. So instead of copying the images I thought I’d try just getting the path to the image in the resource directory and using that in the html file I was creating. That’s how I found out that pathforfile isn’t working for images.

So as a work around I got the pathforfile to locate a text file first and then used gsub to replace the file name with the image name. Unfortunately this still doesn’t work! Looks like the path is ok but the images will not show still. Again works perfectly in the simulator, this is happening on the device only. Think I’ll have to get a small example program up and running to demonstrate. [import]uid: 110859 topic_id: 32111 reply_id: 128172[/import]

OK so I understand what’s going on now thanks to finding this blog: http://www.coronalabs.com/blog/2012/09/26/faq-wednesday-ios-builds-api-docs-and-android/

So looks like I’ll have to rename the pngs to .txt files to make it work, which is fine, as long as I have a workaround. Be nice to have the docs updated with this though as it would have saved me a lot of time! [import]uid: 110859 topic_id: 32111 reply_id: 128272[/import]

I’m also getting the same problem copying JPGs, has anyone got any ideas to solve this? [import]uid: 110859 topic_id: 32111 reply_id: 128146[/import]

Supposedly there’s a bug case already submitted for this (case number 17598 although I can’t actually see it in the list…). I’ve realised the problem is actually with system.pathforfile whereby it isn’t returning the path problem when referencing an image. So instead of copying the images I thought I’d try just getting the path to the image in the resource directory and using that in the html file I was creating. That’s how I found out that pathforfile isn’t working for images.

So as a work around I got the pathforfile to locate a text file first and then used gsub to replace the file name with the image name. Unfortunately this still doesn’t work! Looks like the path is ok but the images will not show still. Again works perfectly in the simulator, this is happening on the device only. Think I’ll have to get a small example program up and running to demonstrate. [import]uid: 110859 topic_id: 32111 reply_id: 128172[/import]

OK so I understand what’s going on now thanks to finding this blog: http://www.coronalabs.com/blog/2012/09/26/faq-wednesday-ios-builds-api-docs-and-android/

So looks like I’ll have to rename the pngs to .txt files to make it work, which is fine, as long as I have a workaround. Be nice to have the docs updated with this though as it would have saved me a lot of time! [import]uid: 110859 topic_id: 32111 reply_id: 128272[/import]