Code not working on Android Device
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Code not working on Android Device
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
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
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
Software Developer
LiveCode
Re: Code not working on Android Device
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.
Re: Code not working on Android Device
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
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?
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
The app is has 2 cards which both open properly.SparkOut wrote: ↑Sat Aug 21, 2021 9:19 amCan 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?
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.
Re: Code not working on Android Device
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?
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
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
Re: Code not working on Android Device
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.
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
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.
-
- 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
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.
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
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Code not working on Android Device
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
This is the offending bit of code:-
This also fails:
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!
It appears that the construct 'put url (tQuery) into myJSONVar' is the problem, where tQuery is a variable holding the constructed URL.
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
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 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
Re: Code not working on Android Device
Tryand 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?
Code: Select all
get url (tQuery)
answer the result
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
Nope, that does not work.SparkOut wrote: ↑Mon Aug 23, 2021 7:55 amTryand see if there is any error message returned.Code: Select all
get url (tQuery) answer the result
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?
yes, it is really a ':' in the filter string.
Re: Code not working on Android Device
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?
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?