Getting started with Google Android

Home / Support / Tutorials / Getting Started / Getting started with Google Android

Required tools and SDKs

Android applications require both a native and a Java part. To get started on Android, you will need the following SDKs and development tools:

Setting up a build environment

Once you have installed the four SDK components, right-click my computer, select properties, and go to the advanced tab. Under environment variables, check that a jdk/bin/ folder is in the PATH environment variable, and check if JAVA_HOME exists and is set to the jdk/ folder. Update both if necessary to complete the configuration for Ant. Update EDGELIB Builder's android.ini with the paths to the various SDKs - you can find it in the edge\tools\edgebuilder\platforms\ folder.

Building using EDGELIB Builder

Creating a .cpp source code file

Create a new folder: C:\projects\helloworld which will contain all project files. Also create a new folder: C:\projects\helloworld\code to contain the source code. Create a new helloworld.cpp file and edit it with a text editor. Paste the following source code sample and save the source file:

helloworld.cpp (72 lines)
  1. /////////////////////////////////////////////////////////////////////
  2. // Code/helloworld.cpp
  3. // One of the EDGELIB tutorial samples for Android
  4. //
  5. // Copyright (c) 2010-2017 Elements Interactive Mobile B.V.
  6. //
  7. //
  8. // Show "hello world" on the screen and exit by hitting a key
  9. /////////////////////////////////////////////////////////////////////
  11. /////////////////////////////////////////////////////////////////////
  12. // Include and link the library                                    //
  13. /////////////////////////////////////////////////////////////////////
  15. //Include EDGELIB
  16. #include "edgemain.h"
  18. /////////////////////////////////////////////////////////////////////
  19. // Class definition                                                //
  20. /////////////////////////////////////////////////////////////////////
  22. //The main class
  23. class ClassMain : public ClassEdge
  24. {
  25.     public:
  26.         ClassMain(void);
  27.         ~ClassMain(void);
  28.         ERESULT OnNextFrame(ClassEDisplay *display, unsigned long timedelta);
  29.         void OnButtonDown(unsigned long bnr, EBUTTONLIST *blist);
  30.         void OnStylusDown(POINT pnt);
  31. };
  34. /////////////////////////////////////////////////////////////////////
  35. // ClassMain: public                                               //
  36. /////////////////////////////////////////////////////////////////////
  38. //ClassMain: constructor
  39. ClassMain::ClassMain(void)
  40. {
  41. }
  43. //ClassMain: destructor
  44. ClassMain::~ClassMain(void)
  45. {
  46. }
  48. //Callback: Called every frame
  49. ERESULT ClassMain::OnNextFrame(ClassEDisplay *display, unsigned long timedelta)
  50. {
  51.     display->buffer.DrawFont(0, 0, &display->fontinternal, "Hello World!");
  52.     return(E_OK);
  53. }
  55. //Callback: Called when the user pressed a key or button
  56. void ClassMain::OnButtonDown(unsigned long bnr, EBUTTONLIST *blist)
  57. {
  58.     Quit();
  59. }
  61. //Callback: Called when the user points the stylus down or clicks the left mouse button
  62. void ClassMain::OnStylusDown(POINT pnt)
  63. {
  64.     Quit();
  65. }
  68. /////////////////////////////////////////////////////////////////////
  69. // The program entry point                                         //
  70. /////////////////////////////////////////////////////////////////////
  72. ClassEdge *EdgeMain(EDGESTARTUP *data){ return(new ClassMain); }

Set up a Android EDGELIB Builder project

Open the EDGELIB Builder and select project -> new. Choose a location to save your project. Create a new folder and save it in c:\projects\helloworld\workspace_android. Click once on "untitled" in the project tree to rename it to Hello World, the name of the project. Then add helloworld.cpp to the source files folder in the project tree. Right click on this folder and select "add files to folder". Browse to helloworld.cpp and open it to add it to the project tree. Save the project file, choose "Android" as the target platform and click build -> rebuild all to build the code, then click build->Build Setup to create the Android packages. The folder c:\projects\helloworld\workspace_android\release\android will now contain several .apk files.
You can upload the package to a connected Android device by supplying the .apk file as an argument to adb:
adb install c:\path\to\application.apk

Advanced Android projects

The build script provides a default AndroidManifest.xml and generated by the Android SDK. After a build you can find these files in the release/Android/project folder. You can provide custom versions of these files by placing your copy in the release/Android folder. Edgebuilder will then use those instead of the default versions. Note that some project settings are included in these files, and any changes will require you to update your custom versions as well.

Custom build solutions

EDGELIB contains two parts for android.
The native part requires some arguments passed to the toolchain: the -DANDROID argument and an include reference to the edgelib headers are needed for compilation. For linking you will need to pass -ledge -ledgerender as the libraries and add the lib/android folder to the library paths.

The java side is contained in edge.jar. You might want to extract it to retrieve the .class files. Since application startup also happens from the Java side, an activity needs to be created with the appropriate name. It has to be a subclass of EdgelibApp, and it should contain a loadlibrary statement referencing the native .so file built in the previous step. The android manifest should be modified such that it point to your subclass.

Latest forum posts