Code not working on Android Device

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

wlaughto
Posts: 30
Joined: Fri Apr 07, 2017 5:06 am

Code not working on Android Device

Post by wlaughto » Fri Aug 20, 2021 2:32 am

I developed my first app about a year ago using Indy (probably version 9.6). Worked fine both on PC and when ported to an Android phone. I have dropped Indy and now only using Community version (9.6.3). The code now works fine running on the PC, however when running on an emulator or ported to a Android device, parts of the code do not work - but other parts do! Doesn't make a lot of sense. Are there limitations with the Community Version that would cause this type of problem?

elanorb
Livecode Staff Member
Livecode Staff Member
Posts: 516
Joined: Fri Feb 24, 2006 9:45 am

Re: Code not working on Android Device

Post by elanorb » Fri Aug 20, 2021 9:53 am

Hi

There are some features in Indy and Business that are not available in Community. The main ones are tsNet, merg extensions and setting passwords on your stacks.

You can see the differences between the Editions here

https://livecode.com/products/livecode- ... m/pricing/

However these features would not work in the IDE either so that is probably not the root of the issue.

You might want to check your Inclusions in the Standalone Application Settings to make sure nothing is being missed when building for Android as missing Inclusions can prevent features working in standalones.

Kind regards

Elanor
Elanor Buchanan
Software Developer
LiveCode

wlaughto
Posts: 30
Joined: Fri Apr 07, 2017 5:06 am

Re: Code not working on Android Device

Post by wlaughto » Sat Aug 21, 2021 2:24 am

Umm, I have downloaded a trial version of Indy. Works perfectly!
Last edited by wlaughto on Sat Aug 21, 2021 3:39 am, edited 1 time in total.

wlaughto
Posts: 30
Joined: Fri Apr 07, 2017 5:06 am

Re: Code not working on Android Device

Post by wlaughto » Sat Aug 21, 2021 3:38 am

I have checked and compared all Standalone Application Build Settings and all are identical. Definitely some sort of disconnect between Community and Indy products!

SparkOut
Posts: 2854
Joined: Sun Sep 23, 2007 4:58 pm

Re: Code not working on Android Device

Post by SparkOut » Sat Aug 21, 2021 9:19 am

Can you say what it is that does not work when you build in the Community version?
If it shows the cards but not working when (say) you try to submit data to a webform, then we can try to narrow it down to (say) implementation of POST commands, etc. Or does it just not open at all?

wlaughto
Posts: 30
Joined: Fri Apr 07, 2017 5:06 am

Re: Code not working on Android Device

Post by wlaughto » Sat Aug 21, 2021 12:00 pm

SparkOut wrote:
Sat Aug 21, 2021 9:19 am
Can you say what it is that does not work when you build in the Community version?
If it shows the cards but not working when (say) you try to submit data to a webform, then we can try to narrow it down to (say) implementation of POST commands, etc. Or does it just not open at all?
The app is has 2 cards which both open properly.
When the app opens, it initialises a bunch of data from external web sites.
One set is a .csv file.
The other data are returned as JSON datasets. These sets are manipluated to extract relevant data depending on user input and displayed on relevant cards.

On the first card, some of the data is not being returned/displayed correctly. Seems to work once correctly, then returns 'rubbish' results.
On the second card, the data is returned and displayed correctly!

This issue is not evident on Indy 9.6.3, but fails on Community 9.6.3.

The 2 screen shots below show the correct output in the first, and using the same input, the failed output in the second.
correct.jpg
failed.jpg

AndyP
Posts: 615
Joined: Wed Aug 27, 2008 12:57 pm
Location: Seeheim, Germany (ex UK)
Contact:

Re: Code not working on Android Device

Post by AndyP » Sat Aug 21, 2021 6:25 pm

Indy versions use tSNet for networking whilst Community uses libURL.
So if you have coded in Indy using the tsNet layer, this would naturally not work in the Community version, could this be the problem?
Andy Piddock
https://livecode1001.blogspot.com Built with LiveCode
https://github.com/AndyPiddock/TinyIDE Mini IDE alternative
https://github.com/AndyPiddock/Seth Editor color theming
http://livecodeshare.runrev.com/stack/897/ LiveCode-Multi-Search

wlaughto
Posts: 30
Joined: Fri Apr 07, 2017 5:06 am

Re: Code not working on Android Device

Post by wlaughto » Sat Aug 21, 2021 10:22 pm

If this were the case, how would I be able to retrieve any data. As indicated above, the first time thru, it works.

How would I know if it is coded for tsNet? I assume by using 'ts' commands? Sorry for the dumb question.

SparkOut
Posts: 2854
Joined: Sun Sep 23, 2007 4:58 pm

Re: Code not working on Android Device

Post by SparkOut » Sat Aug 21, 2021 10:56 pm

Coding the libUrl functions for Android was done in the early days of the platform development and they were somewhat limited. I think there's a difference in workability between GET and POST url calls. If tsNet is available that transparently supercedes the other functionality. (Unless I am misremembering, which is entirely possible.) But it's going to be a lot easier to determine what the issues are if you show the code that does and doesn’t work, then we can be clearer what to look at to resolve this.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9846
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Code not working on Android Device

Post by FourthWorld » Sun Aug 22, 2021 2:26 am

What diagnostic steps have been taken?

If you're using the GPL-governed Community Edition, I'm assuming that's because you also want your app distributed under the GPL - if you can point us to where you make your source code available to customers we may be able to identify where to add diagnostics, and thereby find the root cause of the problem.

As for libURL's HTTP handing, it predates tsNet by about a decade and in my extensive use have found it pretty robust. I can't rule it out until the source is shared, but I would not consider it the prime suspect.

A more likely culprit may be encoding or something of that sort affecting parsing, where tsNet's underlying cURL may be automating some coercion for which a single line applied to the result libURL is providing may suffice.

But that's just a guess. We'll be able to end the guessing and do actual analysis once we see the source.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

andresdt
Posts: 146
Joined: Fri Aug 16, 2019 7:51 pm

Re: Code not working on Android Device

Post by andresdt » Sun Aug 22, 2021 1:47 pm

If your app works fine in the IDE and it doesn't work in android. It seems to me that the Indy version does the dependency inclusion process correctly. While the community version misses something. Try doing the inclusions manually to rule this out. I suspect that the community version is not including the library for working with JSON. That happened to me at some point.

wlaughto
Posts: 30
Joined: Fri Apr 07, 2017 5:06 am

Re: Code not working on Android Device

Post by wlaughto » Sun Aug 22, 2021 10:54 pm

This is the offending bit of code:-

Code: Select all

   put "filters={" & quote & "postcode" & quote & ":" & quote & "2103" & quote & "}"  & "&" into tFilter
   put "https://data.nsw.gov.au/data/api/3/action/datastore_search?" & tFilter & "limit=100000&fields=postcode,lga_name19,notification_date,likely_source_of_infection&resource_id=2776dbb8-f807-4fb2-b1ed-184a6fc2c8aa" into tQuery
   answer information "JSON Query: " & tQuery
   
   
   put url (tQuery) into myJSONVar  -- this appears to be the problem statement
   
   answer information "JSON Data Returned: " & myJSONVar
This also fails:

Code: Select all

put url ("https://data.nsw.gov.au/data/api/3/action/datastore_search?" & tFilter & "limit=10000&fields=postcode,lga_name19,notification_date,likely_source_of_infection&resource_id=2776dbb8-f807-4fb2-b1ed-184a6fc2c8aa") into myJSONVar
Works with Indy 9.6.3 both IDE and Android Emulator
Works with Community 9.6.3 IDE
Does not work with Community 9.6.3 Android emulator

I have manually Included necessary components i.e. are the same (as best I can tell) from Indy to Community.

I have stripped down the code from my original app. It is not the JSON handler that is failing here, but the retrieval of data from the web site.

So, some further information. The following code works!

Code: Select all

   answer information "Getting the total number of Tests ........."
   put url "https://data.nsw.gov.au/data/api/3/action/datastore_search?limit=1&resource_id=945c6204-272a-4cad-8e33-dde791f5059a" into TestVar
   answer information "TestVar: " & TestVar
It appears that the construct 'put url (tQuery) into myJSONVar' is the problem, where tQuery is a variable holding the constructed URL.

SparkOut
Posts: 2854
Joined: Sun Sep 23, 2007 4:58 pm

Re: Code not working on Android Device

Post by SparkOut » Mon Aug 23, 2021 7:55 am

Try

Code: Select all

get url (tQuery)
answer the result
and see if there is any error message returned.
Also is that really a colon in the filter string?
It might be that the Android libUrl library handles special characters differently - what happens if you urlEncode the filters before putting into tQuery?

wlaughto
Posts: 30
Joined: Fri Apr 07, 2017 5:06 am

Re: Code not working on Android Device

Post by wlaughto » Mon Aug 23, 2021 12:06 pm

SparkOut wrote:
Mon Aug 23, 2021 7:55 am
Try

Code: Select all

get url (tQuery)
answer the result
and see if there is any error message returned.
Also is that really a colon in the filter string?
It might be that the Android libUrl library handles special characters differently - what happens if you urlEncode the filters before putting into tQuery?
Nope, that does not work.

yes, it is really a ':' in the filter string.

SparkOut
Posts: 2854
Joined: Sun Sep 23, 2007 4:58 pm

Re: Code not working on Android Device

Post by SparkOut » Mon Aug 23, 2021 4:59 pm

Now I have seen on a computer rather than phone, I can spot that you are using json data in the GET url.
This I think must be a limitation of the libUrl equivalent on Android.
I have made a few quick trials with urlEncoded filters and substituting html entities but not successfully. Is there a method in the API that you can submit the GET string with filters defined as name=value pairs rather than json?

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”