Deploy on Android with XML file

The place to discuss anything and everything about running your LiveCode on Android

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

eddje16
Posts: 21
Joined: Wed Nov 21, 2012 2:41 pm

Deploy on Android with XML file

Post by eddje16 » Wed Nov 21, 2012 2:53 pm

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

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Deploy on Android with XML file

Post by Klaus » Wed Nov 21, 2012 3:06 pm

Hi Erwin,

1. welcome to the forum! :D

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

eddje16
Posts: 21
Joined: Wed Nov 21, 2012 2:41 pm

Re: Deploy on Android with XML file

Post by eddje16 » Wed Nov 21, 2012 3:32 pm

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' ?

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Deploy on Android with XML file

Post by Klaus » Wed Nov 21, 2012 3:51 pm

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 :D

Again:
Do you know what "element" exactly cannot be found?
Or any other hints?


Best

Klaus

eddje16
Posts: 21
Joined: Wed Nov 21, 2012 2:41 pm

Re: Deploy on Android with XML file

Post by eddje16 » Wed Nov 21, 2012 4:05 pm

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'.

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Deploy on Android with XML file

Post by Klaus » Wed Nov 21, 2012 4:40 pm

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 & "",...
...
8)

Sorry, no more ideas in the moment.


Groetjes

Klaus

eddje16
Posts: 21
Joined: Wed Nov 21, 2012 2:41 pm

Re: Deploy on Android with XML file

Post by eddje16 » Wed Nov 21, 2012 5:06 pm

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! :-)

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Deploy on Android with XML file

Post by Klaus » Wed Nov 21, 2012 5:22 pm

Hi Erwin,

I do not develop for Android, but just post your link, I can make it work, I'm a moderator :D


Best

Klaus

eddje16
Posts: 21
Joined: Wed Nov 21, 2012 2:41 pm

Re: Deploy on Android with XML file

Post by eddje16 » Wed Nov 21, 2012 5:49 pm

Hmm...it is saying: Your account does not have permission to post links or domain/page references.

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Deploy on Android with XML file

Post by Klaus » Wed Nov 21, 2012 5:56 pm

Hi erwin,

then put some spaces into the URL to fool the forum scripts! 8)
I will make it work!


Best

Klaus

eddje16
Posts: 21
Joined: Wed Nov 21, 2012 2:41 pm

Re: Deploy on Android with XML file

Post by eddje16 » Wed Nov 21, 2012 6:55 pm

dl dropbox com / s / mzgh30s9p91adhk / voetbalnavi.zip


eddje16
Posts: 21
Joined: Wed Nov 21, 2012 2:41 pm

Re: Deploy on Android with XML file

Post by eddje16 » Wed Nov 21, 2012 7:05 pm

Thanks!

Can you/or someone you know who develops for Android look at it? ;-)

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Deploy on Android with XML file

Post by Mark » Thu Nov 22, 2012 11:54 am

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
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

eddje16
Posts: 21
Joined: Wed Nov 21, 2012 2:41 pm

Re: Deploy on Android with XML file

Post by eddje16 » Thu Nov 22, 2012 1:47 pm

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?

Post Reply