Page 1 of 2
Deploy on Android with XML file
Posted: Wed Nov 21, 2012 2:53 pm
by eddje16
Hello,
First I would like to say what a great product Livecode is. I don't have any programming skills, but can work with Livecode quite easily.
The problem:
I want to deploy a XML file with my stack. Everything is working in Livecode itself, but when I deploy it to Android, it gives me an error: "xmlerr, can't find element." I loaded the file in the Copy Files areas.
on mouseUp
loadPreferences
end mouseUp
command loadPreferences
local tTree
put readPreferencesToXMLTree() into tTree
if tTree is empty then
exit loadPreferences
end if
processPreferencesTree tTree
revDeleteXMLTree tTree
end loadPreferences
private function readPreferencesToXMLTree
local tPreferencesFile, tResult
put specialFolderPath("documents") & "/Preferences.xml" into tPreferencesFile
if there is not a file tPreferencesFile then
put URL("binfile:" & specialFolderPath("documents") & "/Preferences.xml") into URL("binfile:" & specialFolderPath("engine") & "/Preferences.xml")
end if
put the result into tResult
if tResult is not empty then
answer error "Failed to read preferences file at location: " & tPreferencesFile
return empty
end if
local tTree
put revCreateXMLTreeFromFile(tPreferencesfile,false,true,false) into tTree
if tTree is not an integer then
answer error "Failed to process preferences file with error: " & tTree
return empty
end if
return tTree
end readPreferencesToXMLTree
I'm deploying it on a Nexus with version 2.3.3.
Can anyone help?
Grtz. Erwin
Re: Deploy on Android with XML file
Posted: Wed Nov 21, 2012 3:06 pm
by Klaus
Hi Erwin,
1. welcome to the forum!
2. At first glance it looks like you swapped the soruce and destination here:
Code: Select all
...
if there is not a file tPreferencesFile then
put URL("binfile:" & specialFolderPath("documents") & "/Preferences.xml") into URL("binfile:" & specialFolderPath("engine") & "/Preferences.xml")
## You cannot write to the ENGINE folder!
end if
...
I'm sure it should read:
Code: Select all
...
if there is not a file tPreferencesFile then
put URL("binfile:" & specialFolderPath("engine") & "/Preferences.xml") into URL("binfile:" & specialFolderPath("documents") & "/Preferences.xml")
end if
...
If that is not the problem, it might be the content of the XML file.
Do you know what "element" exactly cannot be found?
Best
Klaus
Re: Deploy on Android with XML file
Posted: Wed Nov 21, 2012 3:32 pm
by eddje16
Wow Klaus, that's a fast reply!
1. Thank you.
2. My mistake, but that's not it unfortunately.
The code itself works fine in LiveCode, so I guess it is not the combination of the XML with the code.
I also put a button with a field on the emulator to read the 'engine' and 'documents' path.
For the documents it is saying: /data/data/com.lam.navi/Preferences.xml
For the engine it is saying: /data/app/com.lam.navi-1.apk/Preferences.xml
This is the first time I'm using the Identifier.
I guess there is something wrong with the path to the ' engine' ?
Re: Deploy on Android with XML file
Posted: Wed Nov 21, 2012 3:51 pm
by Klaus
Hi erwin,
hm, that's why we have these specialfolderpaths, so we need not to mess around with the real and cryptic folder and pathnames on mobile devices.
But I don't think the path is incorrect! It it was then other users would already have complained a LOT about this
Again:
Do you know what "element" exactly cannot be found?
Or any other hints?
Best
Klaus
Re: Deploy on Android with XML file
Posted: Wed Nov 21, 2012 4:05 pm
by eddje16
Hehe..
This is a part from the XML file:
<Clubs>
<Achilles1894 club="Achilles 1894" Adres="M.L. Kingweg 11" Plaats="Assen" Telefoonnummer="0592-315710">
</Clubs>
End this is the last part of the code under the button:
command processPreferencesTree pTree
put text of field "birthstate" into tNaam
replace " " with "" in tNaam
replace "'" with "" in tNaam
replace "/" with "" in tNaam
replace "0" with "" in tNaam
replace "(" with "" in tNaam
replace ")" with "" in tNaam
replace "." with "" in tNaam
replace "\" with "" in tNaam
replace "’" with "" in tNaam
replace "-" with "" in tNaam
go to the next card
put revXMLAttribute(pTree,"/clubs/" & tNaam & "","Plaats") into tPlaats
local tAdres
put revXMLAttribute(pTree,"/clubs/" & tNaam & "","Adres") into tAdres
local tTel
put revXMLAttribute(pTree,"/clubs/" & tNaam & "","Telefoonnummer") into tTel
local pVere
put revXMLAttribute(pTree,"/clubs/" & tNaam & "","club") into pVere
put tAdres into field "adres"
put tPlaats into field "result"
put tTel into field "telefoon"
put pVere into field "bord"
end processPreferencesTree
In the emulator when I click the button, and go to the next card I see 1/10 second the right text in the field, but than it changes to 'xmlerr, can't find element'.
Re: Deploy on Android with XML file
Posted: Wed Nov 21, 2012 4:40 pm
by Klaus
Dag Erwin,
hmm, looks OK so far, I think tNaam is correct in hte end?!
But I ask myself why you add empty/NADA after tNaam -> tNaam & "" in
...
put revXMLAttribute(pTree,"/clubs/" & tNaam & "",...
...
Sorry, no more ideas in the moment.
Groetjes
Klaus
Re: Deploy on Android with XML file
Posted: Wed Nov 21, 2012 5:06 pm
by eddje16
Damn, I can't figure it out
Can I get permission to post a link to dropbox? I hope you can help me when you see the stack yourself.
Groetjes terug!

Re: Deploy on Android with XML file
Posted: Wed Nov 21, 2012 5:22 pm
by Klaus
Hi Erwin,
I do not develop for Android, but just post your link, I can make it work, I'm a moderator
Best
Klaus
Re: Deploy on Android with XML file
Posted: Wed Nov 21, 2012 5:49 pm
by eddje16
Hmm...it is saying: Your account does not have permission to post links or domain/page references.
Re: Deploy on Android with XML file
Posted: Wed Nov 21, 2012 5:56 pm
by Klaus
Hi erwin,
then put some spaces into the URL to fool the forum scripts!
I will make it work!
Best
Klaus
Re: Deploy on Android with XML file
Posted: Wed Nov 21, 2012 6:55 pm
by eddje16
dl dropbox com / s / mzgh30s9p91adhk / voetbalnavi.zip
Re: Deploy on Android with XML file
Posted: Wed Nov 21, 2012 6:59 pm
by Klaus
Re: Deploy on Android with XML file
Posted: Wed Nov 21, 2012 7:05 pm
by eddje16
Thanks!
Can you/or someone you know who develops for Android look at it?

Re: Deploy on Android with XML file
Posted: Thu Nov 22, 2012 11:54 am
by Mark
Hi,
I built a standalone and tried the app, but unfortunately it crashes as soon as it tries to access the XML file.
Btw there is a Dutch LiveCode forum at
http://runrev.info/rrforum/
Kind regards,
Mark
Re: Deploy on Android with XML file
Posted: Thu Nov 22, 2012 1:47 pm
by eddje16
Mark wrote:Hi,
I built a standalone and tried the app, but unfortunately it crashes as soon as it tries to access the XML file.
What can you conclude out of this?
Is there something wrong with the XML file itself or is it the code that tries to access the XML file?