On most platforms a DukeScript application is a regular Java
application - e.g. it has a
main method that handles the initialization and
then starts the appropriate presenter. If you use
our archetypes, you’ll
iOSMain classes that do exactly this.
However one platform is different - there is no main method on Android, you need to create own activity. By default DukeScript provides you an activity which handles everything behind the scene automatically. This works fine, until you realize you need some special service from the Android runtime. Such service is usually only available via an instance of an activity. And you don’t have such instance!
Update: Since February 2017, you can get that instance easily - read about enhancements in 0.17 archetypes and see how they can simplify the boot of a DukeScript Android application!
Recently there has been a discussion on our forum and here is the best solution to the problem: create a decorating activity:
You’ll also need to register this Activity in your AndroidManifest.xml. The full diff of required changes is available in one of Jaroslav’s (the designer of HTML/Java API) pet projects. Check it out here: Karel the Game.