Page 1 of 1

Network Access for Standalone Applications

Posted: Wed Feb 03, 2021 4:50 am
by cbitterfield
I am working on an application for Android on my MACBook Pro. (Community Version LC9) and BigSur.

The application works fine on the Mac. However when I compile for standalone use the application has no access to the network.

I am using a restAPI webserver on my network. The virtual Android, Real Tablet and my mac via chrome can all access the RESTapi no problem.

All standalone applications have no access to the network. Virtual, Tablet or MAC. I have tried every setting in standalone applications and I can see that android tablets have no access by default and there does not seem to be a way to turn this on.

Is this a community version issue? or some setting I am missing. I create a very basic application from this guide:
"How to Request a Resource from a REST API" from Livecode lessons.

It works in Livecode but not as a stand alone application.

Re: Network Access for Standalone Applications

Posted: Wed Feb 03, 2021 8:45 am
by stam
Hi cbitterfield,
Might be worth manually setting inclusions in the standalone settings and ensuring internet, SSL, JSON and mergJSON
are included (along with any other functionality needed by your app).
When things work in the IDE but not the standalone, it’s usually because of missing inclusions (the automatically detect inclusions setting doesn’t work that well!).

Hope that helps,
Stam

Re: Network Access for Standalone Applications

Posted: Wed Feb 03, 2021 11:28 am
by bogs
This same question came up recently elsewhere, Jacque may have already provided the answer you need.

Re: Network Access for Standalone Applications

Posted: Wed Feb 03, 2021 2:29 pm
by cbitterfield
Followed the instructions and still not working:

Inclusions
  • Switch Button
    Spinner
    Browser
    JSON Library
    Time zone Library
    DataGrid
    Internet
    SSL & Encryption
    Answer Dialog
    Ask Dialong
    mergJSON
Android Settings
  • Requirements and Restrictions
    - Telephony CDMA
    - Telephony GSM

    Application Permissions
    Write External Storage
    Internet
    Vibration
    Idel Timer
Using Virtual Tablet for testing
RESTapi works via Chrome on virtual Tablet
No Response on get JSON from URL on Application. (Just hangs)
No data transferred


On the Application Permissions; no permissions granted is showing.
I can't enable permisions (all) it doesn't stick.
Application is signed for development.
During installation it does say no special permissions required.

Also OSX (APP) does work now.

The RESTapi is running http unencrypted and does not require any keys or security. (simple get provides response)

Re: Network Access for Standalone Applications

Posted: Wed Feb 03, 2021 6:15 pm
by jacque
Virtual emulators do not always respond like real devices. Do you have access to a real Android device?

You could also try adding the TSNet inclusion, it adds more advanced features to the internet library (you should include both.)

Re: Network Access for Standalone Applications

Posted: Wed Feb 03, 2021 10:49 pm
by cbitterfield
I checked in with an Android 9 tablet. (Same issue)

TSNet is only in LiveCode Indy or Business.

Re: Network Access for Standalone Applications

Posted: Thu Feb 04, 2021 1:03 am
by cbitterfield
Is there anyway to get this to work on Community Edition or Community Plus Edition?

Re: Network Access for Standalone Applications

Posted: Thu Feb 04, 2021 2:17 am
by jacque
I'm sure you can make it work but there's not enough info to tell what's wrong. Do you get the result after executing an internet interaction? You can "answer the result" or write it to a log. That may tell you something. Also extensive logging can allow you to see where in the scripts things go wrong. On mobile I usually write the log to a file in the documents folder and then add a temporary button that puts the log text into a field so I can read it.

Or you could post the relevant part of the script here, maybe someone will notice a problem.

Re: Network Access for Standalone Applications

Posted: Fri Feb 05, 2021 11:00 am
by elanorb
Hi

This might be because of the version of Android your devices are using and the fact that the RESTapi is running http unencrypted. Starting with Android 9 cleartext support is disabled by default which prevents http connections.

There is a bug report for this which includes some options for workarounds.

https://quality.livecode.com/show_bug.cgi?id=22400

I hope that helps.

Elanor

Re: Network Access for Standalone Applications

Posted: Fri Feb 05, 2021 3:21 pm
by cbitterfield
How do I add this file to the Livecode build? Is this an external file? or is there some way to set it?

v/r

Re: Network Access for Standalone Applications

Posted: Mon Feb 08, 2021 4:42 pm
by elanorb
Hi

If you want to try option 2, which is probably the simpler option, you would need to apply the suggested changes to the Android manifest template in the LiveCode app.

You said you are on Mac so to find this file choose "Show Package Contents" on the LiveCode app bundle. The file you need to modify is in Contents/Tools/Runtime/Android/Manifest.xml. I suggest making a copy of the original file before trying the workaround so you can go back to the original file if you need to.

I hope that helps.

Kind regards

Elanor

Re: Network Access for Standalone Applications

Posted: Wed Mar 10, 2021 8:13 pm
by jekyllandhyde
Elanor,

I need to modify the manifest.xml file to include http support for an arduino web server which can't do https, at least until Panos's fix gets released in the next Livecode version. I am completely stumped how to do this on a mac? When I build the apk, Android studio only allows viewing the package contents, not modifying. I tried including the appropriate xml entry into the included files so it would be included but that doesn't work. Sorry I'm not the most technical so perhaps this isn't possible yet?

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<manifest ...>
    <application
        ...
        android:usesCleartextTraffic="true"
        ...>
        ...
    </application>
</manifest>

Any advice appreciated.

Cheers, Adam

Re: Network Access for Standalone Applications

Posted: Thu Mar 11, 2021 5:20 pm
by elanorb
Hi Adam

You actually make the changes in the LiveCode app bundle, so the updated version of the manifest file is included in the Android apps you build.

Go to Applications, find your LiveCode app and then follow the instructions to choose "Show Package Contents" etc. The change will then be applied to all Android standalones you make, hopefully that will not be a problem.

Please let me know if you need any further clarification.

Kind regards

Elanor

Re: Network Access for Standalone Applications

Posted: Thu Mar 11, 2021 6:42 pm
by jekyllandhyde
Thanks, I think I am cluing in now.

What you are saying is go here on my Mac: /Applications/LiveCode Indy 9.6.1.app/Contents/Tools/Runtime/Android/manifest.xml

edit the manifest file and it will include the cleartraffic entry on every android build...

It worked, thanks!

Re: Network Access for Standalone Applications

Posted: Fri Mar 12, 2021 11:47 am
by elanorb
Great! Glad to hear you got it working.

The fix is targeted to be included in 9.6.3 so you won't have to worry about it after that. If you do update, when 9.6.2 is released, or if you have to reinstall or are you using a different machine you will need to reapply the manual fix.

Kind regards

Elanor