Page 1 of 2

Code not working on Android Device

Posted: Fri Aug 20, 2021 2:32 am
by wlaughto
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?

Re: Code not working on Android Device

Posted: Fri Aug 20, 2021 9:53 am
by elanorb
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

Re: Code not working on Android Device

Posted: Sat Aug 21, 2021 2:24 am
by wlaughto
Umm, I have downloaded a trial version of Indy. Works perfectly!

Re: Code not working on Android Device

Posted: Sat Aug 21, 2021 3:38 am
by wlaughto
I have checked and compared all Standalone Application Build Settings and all are identical. Definitely some sort of disconnect between Community and Indy products!

Re: Code not working on Android Device

Posted: Sat Aug 21, 2021 9:19 am
by SparkOut
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?

Re: Code not working on Android Device

Posted: Sat Aug 21, 2021 12:00 pm
by wlaughto
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

Re: Code not working on Android Device

Posted: Sat Aug 21, 2021 6:25 pm
by AndyP
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?

Re: Code not working on Android Device

Posted: Sat Aug 21, 2021 10:22 pm
by wlaughto
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.

Re: Code not working on Android Device

Posted: Sat Aug 21, 2021 10:56 pm
by SparkOut
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.

Re: Code not working on Android Device

Posted: Sun Aug 22, 2021 2:26 am
by FourthWorld
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.

Re: Code not working on Android Device

Posted: Sun Aug 22, 2021 1:47 pm
by andresdt
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.

Re: Code not working on Android Device

Posted: Sun Aug 22, 2021 10:54 pm
by wlaughto
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.

Re: Code not working on Android Device

Posted: Mon Aug 23, 2021 7:55 am
by SparkOut
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?

Re: Code not working on Android Device

Posted: Mon Aug 23, 2021 12:06 pm
by wlaughto
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.

Re: Code not working on Android Device

Posted: Mon Aug 23, 2021 4:59 pm
by SparkOut
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?