Android won't copy files

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

yachris
Posts: 20
Joined: Sat May 21, 2011 1:26 am

Android won't copy files

Post by yachris » Sat May 28, 2011 5:52 pm

Hello,

Trying to test deploying to Android... and everything works (yay!) except for copying files to the app.

In the "Standalone Application Settings" page, I've put a file that I want to have copied. I've got code that reads the file, and puts it into a field.

This works fine on iOS, but fails on Android, both in the emulator and on my Android phone.

As near as I can tell, I've got everything installed and set up properly.

Thanks for any help!

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7390
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Android won't copy files

Post by jacque » Sat May 28, 2011 11:25 pm

What file path are you using? Files included in the app are in:

specialFolderpath("engine")

But you can't write any files there, it is read-only (same as iOS.) You'll need to write copies to specialFolderpath("documents"). That's the only permanent location Android has for app data files.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

yachris
Posts: 20
Joined: Sat May 21, 2011 1:26 am

Re: Android won't copy files

Post by yachris » Sat May 28, 2011 11:41 pm

Hi Jacque,

Thanks for the reply... sorry I wasn't clear. Yes, I'm using specialFolderPath("engine") as the directory. I don't want to write files there, I just want some text files and sqlite databases (all read-only) to be copied there, so the app can use them.

I've specified some files in the "Copy Files" pane of the "Standalone Application Settings" dialog; they get copied (and are available to the app) when I run under iOS, but they don't get copied (I asked it to list the files there) and so aren't available under Android.

I'm hoping it's a misconfiguration on my part, otherwise I should probably file a bug report.

yachris
Posts: 20
Joined: Sat May 21, 2011 1:26 am

Re: Android won't copy files

Post by yachris » Sat May 28, 2011 11:46 pm

Here's a stack that shows off the behavior I'm seeing... maybe someone can get it working on Android as well as iOS?

THANKS!
Attachments
ShowFile.zip
Stack that shows the Android copy failure
(2.73 KiB) Downloaded 367 times

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7390
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Android won't copy files

Post by jacque » Sun May 29, 2011 2:35 am

I think it's a bug. I'm getting a list of non-existent files which look like the ones Hanson showed in his conference talk. Your foo.txt file never does show up, though it's listed correctly in the custom property the standalone builder uses. I'd report it. There's no other workaround, the engine has to do the inclusion, so tag the report as major or critical.

Include your sample stack, it does a very good job of showing the problem.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

yachris
Posts: 20
Joined: Sat May 21, 2011 1:26 am

Re: Android won't copy files

Post by yachris » Sun May 29, 2011 3:25 am

Cool, thanks Jacque. Just out of curiosity (and cluelessness :-) ) what is this Hanson conference talk? Is it available online somewhere?

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7390
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Android won't copy files

Post by jacque » Sun May 29, 2011 4:01 am

yachris wrote:Cool, thanks Jacque. Just out of curiosity (and cluelessness :-) ) what is this Hanson conference talk? Is it available online somewhere?
It was one of the presentations at the RevLive Conference last month. The entire conference was videotaped and is available for viewing if you purchase the package (you may still be able to, check the online store. It's well worth it, there is about 40 hours of presentations and instruction there. Best conference they've ever had.) Hanson is one of the engineers at RunRev and he did a presentation on programming artificial intelligence with LiveCode. His artifically intelligent test creatures were fish -- and that goldfish file looks suspiciously like one he was using. The only strange thing is that his presentation wasn't done on mobile, it was a standard LiveCode stack. So all I can figure is that maybe he was testing for mobile and the engine accidentally got compiled with his files in it.

Or maybe I'm entirely off base. Who knows. All I know is that they aren't "foo.txt", that's for sure. You see four odd files in the list too, right? It isn't just my build?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

yachris
Posts: 20
Joined: Sat May 21, 2011 1:26 am

Re: Android won't copy files

Post by yachris » Sun May 29, 2011 6:30 pm

jacque wrote:You see four odd files in the list too, right? It isn't just my build?
Absolutely right. They are:
  • init.rc
    init.goldfish.rc
    init
    default.prop
And when I hit the "Show foo.txt" button, it shows the file location as:
  • /data/app/com.yourcompany.yourapp-1.apk/foo.txt
Thanks for the help!

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7390
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Android won't copy files

Post by jacque » Mon May 30, 2011 1:00 am

Yeah, same four weird file names. The path shows foo.txt but that's just the string your script constructed, not confirmation the file actually is there. Since the content isn't being read, I suspect it isn't.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

yachris
Posts: 20
Joined: Sat May 21, 2011 1:26 am

Re: Android won't copy files

Post by yachris » Tue May 31, 2011 10:22 pm

Okay, submitted as bug #9565.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7390
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Android won't copy files

Post by jacque » Wed Jun 01, 2011 7:30 pm

Thanks for putting in the bug report.

I'm kind of curious what's in the goldfish file though. :)
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

yachris
Posts: 20
Joined: Sat May 21, 2011 1:26 am

Re: Android won't copy files -- FIXED!

Post by yachris » Wed Jun 01, 2011 7:48 pm

Wow, that was fast! I got a reply today from Mark at RunRev:
Hi Chris,

Thanks for the report.

Looking at your stack there are two changes you can make to cause it to work.

The first is in the 'Show files' button. Here, setting the folder to
specialFolderPath("engine") & slash causes the file listing to work properly.
(i.e The Android engine is currently requiring a trailing slash on the engine
folder to make it work - this is unique to the engine folder; other folders
don't require it).

The second is in the 'Show foo.txt' button. Here, you need to "open file ...
for text read" - at the moment you are opening for 'update' which is not
possible as you cannot write to files within the engine folder. (This is
because the engine 'folder' isn't a folder at all; but is actually part of the
APK zip file that is copied to the device / emulator).

We'll look further into both of these issues. The first is definitely a bug;
the second is more something that should be consistent as (from memory) the iOS
app bundle folder is read-only (this might be a difference between iOS
simulator and device though).

Warmest Regards,

Mark.
Tried the fixes and they work. So kudos to the team, and I learned something today! I'll attach the fixed Stack in case anyone is curious.
jacque wrote:I'm kind of curious what's in the goldfish file though. :)
Yeah, me too :-)
Attachments
ShowFileFixed.zip
(2.87 KiB) Downloaded 379 times

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7390
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Android won't copy files

Post by jacque » Wed Jun 01, 2011 9:31 pm

I'm kicking myself for not noticing the "open for update" thing. We all know you can't write to the engine folder, and I knew that a plain "open file" command will open for update, but I didn't put the two together.

I usually just use the "get URL" syntax when grabbing a file's content, which bypasses the issue. Will make a mental note about "open file", which probably I'll forget again by tomorrow...

A toast to goldfish everywhere.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Gene
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 75
Joined: Wed Mar 09, 2011 6:48 pm

Re: Android won't copy files

Post by Gene » Wed Jun 01, 2011 10:40 pm

Wow, did this thread cut to the chase! Thanks! I spent a lot of time trying to find out if my file, entered into "Copy Files" in the standalone settings configuration was actually going to the device. Then, the "ShowFileFixed.zip" app, when loaded on my Android, showed that the my file was actually on the device under specialFolder("Engine"). I had written a similar utility to examine the Engine and the Documents folders, and came up with nothing until I learned about the slash needed behind specialFolder("Engine").

However...so near, yet so far. My file is called "Stairs.wmv," and I want to play it on my Android through LC. It plays from the gallery when uploaded manually, so I'm pretty sure the Android video mechanism will play a ".wmv" video.

The video plays in the Windows authoring environment with the following, where the .wmv file is in the same directory as the LC file:

set the filename of "Player 1" to "Stairs.wmv"
play player "Player 1"

However, I haven't found any variation on the following that will work, although it appears that the .wmv file exists under specialFolder("Engine"):

set the filename of "Player 1" to "Stairs.wmv", or set the filename of "player 1 to specialFolder("Engine") & "/Stairs.wmv", or set the filename of "player 1" to specialFolder("Engine") & slash & "Stairs.wmv".

I will continue to try to hammer this out, but it would be great if someone could apply the magic touch to this problem.

BTW - I found the following in Wikipedia about the Android Goldfish:

"Goldfish
Android SDK isn't targeted for a special (ARM) SoC. Instead, they use QEMU to create a virtual ARM SoC called Goldfish. The virtual ARM SoC boots an (currently 2.6.23, m5-rc14) ARM Linux kernel with Goldfish platform support on your (x86) Windows, MacOS X or Linux host."

Sounds like a shark rather than a goldfish. Maybe some of you folks are eqiupped to probe into this, but I'll just be satisfied to play my video file.

Cheers - Gene

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4164
Joined: Sun Jan 07, 2007 9:12 pm

Re: Android won't copy files

Post by bn » Thu Jun 02, 2011 12:14 am

Hi Gene,

from the Android release notes:
play soundFile [ looping ]
p 21-22
so you code would be

Code: Select all

put thePathToMySoundfile into tSoundPath
play tSoundPath
not tested since I dont have the Android SDK, according to the documentation this works the same as in iOS. There it works.
also have a look at 'the sound' and 'play empty' in the release notes.

Kind regards

Bernd

Post Reply