Listing Android externals, commands and function in LiveCode

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, LCMark

Post Reply
SamanthaLC
Posts: 22
Joined: Sat Jul 20, 2013 11:57 pm

Listing Android externals, commands and function in LiveCode

Post by SamanthaLC » Wed Sep 25, 2013 6:03 am

Hello engine coders!

I am trying to list the externals which are available in an Android LiveCode app, as well as the commands and functions that are provided by these externals.

In Windows I can just use:

Code: Select all

   put the name of this stack into theStack
   put the externalPackages of stack theStack into extPackages
   put the externalCommands of stack theStack into extCommands
   put the externalFunctions of stack theStack into extFunctions
And see the externals available in the variables extPackages, and the commands and functions provided by the externals in extCommands and extFunctions respectively. On Android, even though I know the SQLiteDB external is loaded and working, I do not see anything from these calls.

Are these methods supported for Android externals?

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1561
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: Listing Android externals, commands and function in Live

Post by monte » Wed Sep 25, 2013 6:36 am

Yes... mobile externals are loaded differently. They have a global scope as apposed to a stack based scope. We probably need global properties but we don't have them at the moment.
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

SamanthaLC
Posts: 22
Joined: Sat Jul 20, 2013 11:57 pm

Re: Listing Android externals, commands and function in Live

Post by SamanthaLC » Thu Sep 26, 2013 6:16 am

Ok, that explains the behavior I was seeing! Thank you for the reply.

Is there any other way to confirm that a LiveCode external on Android is properly loaded before trying to call commands contained in it? I am trying to have my stack behave gracefully in the face of failure.

Thanks again! :)

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1097
Joined: Thu Apr 11, 2013 11:27 am

Re: Listing Android externals, commands and function in Live

Post by LCMark » Fri Oct 04, 2013 9:12 am

@SamanthaLC: As @monte states, externals on mobile aren't tied to a stack they are global (mainly because on iOS they have to be linked in with the main engine - no dynamic libraries allowed). This means the 'external*' properties of stacks don't work.

If an external is included in copy files (and assuming it has a build for the target platform) then it will be linked in and loaded when the app is launched. If an external fails to load the app will terminate on startup and not work - so, essentially, if you include an external for iOS in an iOS app and your code runs you can be sure the external is there.

SamanthaLC
Posts: 22
Joined: Sat Jul 20, 2013 11:57 pm

Re: Listing Android externals, commands and function in Live

Post by SamanthaLC » Fri Oct 04, 2013 2:38 pm

runrevmark wrote:If an external is included in copy files (and assuming it has a build for the target platform) then it will be linked in and loaded when the app is launched. If an external fails to load the app will terminate on startup and not work - so, essentially, if you include an external for iOS in an iOS app and your code runs you can be sure the external is there.
This sounds like it would be problematic in terms of handling failures gracefully.

One of the things I like about being able to see what externals are loaded and the methods they provide on Windows is that if for some reason the external fails to load, or is not found, I can present a message to the user about the issue and suggest possible fixes.

For example if an external depends on a particular version of the C++ Runtime to be installed - if it does not load, perhaps be sure you have this package installed and try again.


Would it be possible to get global properties related to Externals on iOS and Android since they do not have stack scope as you say? Or is this a very large undertaking with lots of new code required to support it?

I am currently dealing with an issue on mobile and the behavior is as you describe: my application crashes if there is a problem with the External. I hoped to find an easy way to verify an External would be usable before attempting to call its commands and avoid a crash.

Thank you Mark and Monte for all the information! I am soaking up LiveCode Engine Development as fast as I can and hope to be able to contribute back to this community one day soon :)

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1097
Joined: Thu Apr 11, 2013 11:27 am

Re: Listing Android externals, commands and function in Live

Post by LCMark » Fri Oct 04, 2013 3:27 pm

@SamanthaLC: The problem with iOS is that the externals cannot be loaded dynamically - the code has to be statically linked into the executable that is produced. This means the external code has to be written / compiled so that it will load on all the iOS versions you need to support. Adding global properties to the mobile engines so you can check which externals loaded wouldn't be very hard to do and I guess it would offer an element of consistency, but it actually wouldn't be very helpful either since if the engine gets to a point where it can tell you that information then it means that the external has loaded... The external is, after building, part of the main application execution as it is part of the app's executable image.

One typical problem is building an external against a new iOS SDK using new functionality (say in iOS 7) and then trying to run it in an older simulator or device without weak-linking the new Frameworks, or in a similar situation (where things are weakly linked) using functions or classes without checking they are present (i.e. a nil pointer check).

If you can give more details about the problem you are encountering then I'm sure @monte and I can help to get things working... In particular what errors are you getting in the Console and are you getting any crash reports?

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1097
Joined: Thu Apr 11, 2013 11:27 am

Re: Listing Android externals, commands and function in Live

Post by LCMark » Fri Oct 04, 2013 3:35 pm

Of course, I just realized you were asking about Android externals specifically! Android is a little different from iOS in that the externals are dynamic libraries... Is the external you are trying to write dependent on non-system (native code) libraries and such being installed (which are not included in the app)? Or non-system Java packages (which are not included in the app)?

It should be possible to determine what is causing your externals not to load by looking at 'adb logcat' when running the app...

Post Reply

Return to “Engine Contributors”