English|Português|Español
UserPasswordLogin

HOME
SESSIONS
INFO
icono GXandroid

My first Android application or, rather, getting started with GeneXus Evolution 2

Gabriel Icasuriaga, from the GeneXus Community in Uruguay, shares his first experience developing an Android application with GeneXus X Evolution 2.
To get started, I’ve decided to follow the instructions on Artech’s wiki to develop an application for the much talked-about Smart Devices. So, I will use this guide and write my comments and impressions as I move forward, hoping that it will be useful to anyone who wants to quickly begin to configure the product and run their first application, thus opening the possibility to create their own applications.
At first, we will achieve an application that has something similar to this interface:





 
The first experience is based on this beta version (beta 1 of GeneXus X Evolution 2) which at present can only generate with Ruby and for Android. In future releases more generators will be added, including support for iOS/Apple and RIM/Blackberry, and the published updates will be Night Builds.

You can sign up as a beta tester here and once you’ve registered, I recommend that you read the forum especially created for this version, so if you face a problem when you're starting to use the tool, most likely you will find that it has already happened to someone else so you can use his/her experience and continue to enjoy the testing.

The user’s guide that goes with this tutorial can be downloaded here. In addition, you may want to print it in order to avoid going back and forth with Alt + Tab, and to have the images associated with each step readily available to be able to better locate the references provided in these instructions. 



 
Below you will find my experience following the step-by-step instructions for the development of an Android application with GeneXus X Evolution 2:

Step 0: Basic Prerequisites: The Android emulator and Ruby support must be installed.

Actually, it involves more than that because it means that you need to install Evo2 and the Java JDK, but it is clearly explained here so we will continue following this guide to install Android.
1) Sign up as a beta tester, download and install Evolution 2 from here.

Note: Ruby support must be installed; remember that this generator only supports MS SQL Server and MySQL.

If you haven't installed Ruby support, once the installation of Evolution 2 is complete, run the install.bat that is located in the folder C:\Program Files (x86)\Artech\Genexus\GCEv2\gxruby\win.

You will need licenses to use this product. The requirements are described upon registration, but since it is a different product it doesn’t have an effect on the existing licenses.

2) Install the Android SDK, which brings the emulator to make the tests so you don't need to have a device with Android to run them.

Tip: This is the stage in which you need to be more careful, so pay attention and follow each step slowly, or better yet, read the entire section before getting started because later on it can save you the time spent trying to find out why "it doesn't work."

Android’s prerequisites include Java JDK 1.6. Note that JRE is not enough. In my case I had already installed it, but if you don't have it you must install it before the SDK. It can be downloaded here, and be careful because it also installs the JRE.

The complete list of Android prerequisites can be reviewed here and the Quick Start guide can be found here.

Once the JDK is installed, download Android’s SDK for Windows here (note that this link takes you directly to the download process).

This is a ZIP file that generates a folder called “android-sdk-windows.” It doesn’t bring an installer, so it will be installed in the same place in which you unzip it; this path will be requested in the model properties, but we will get there later.

Add the folder “android-sdk-windows\tools” to the Windows path. Even though it isn’t compulsory, it will be useful to execute a debug, updates or other tools from the command line.

In the folder where you unzip the file you will find a program called “SDK Manager”. Run it and indicate the packages you want to have installed by looking at this image taken from the wiki. Compare your selection with this image before clicking on “Install”.

Note:
The default option has more packages selected than the ones you need. In order to clear the rest of the packages, click on the desired package and below, to the right, choose the "Reject" option. This will cause an "x" to be displayed on the package to be removed, and this must be done for each one individually.

The Google API packages at the beginning of the line are marked with “?” by default. In order to install them, follow the same steps required to remove them, but choose the “Accept” option instead and the “?” symbol will be replaced with a check mark.

In sum, only install SDK Platform 2.2 and 2.1 and Google APIs 8 and 7.

When the installation is complete, if everything went well the Installed Pack ages in your PC should look similar to the image mentioned above.

3) Installation of the JDK; it was explained as a prerequisite to install the SDK.

4) Now is the time to create the KB, according to the step-by-step guide published by Artech on the Community Wiki.


Step 1: Create a KB with Evolution 2 and Ruby

Multi-language is not supported at the moment, so leave English as is by default.
Interesting fact: After creating the KB, look at the “domains” folder. You will see that there are some new ones and they will be associated with standard responses of the devices; for instance, if an attribute based on an "Email" domain is added, upon clicking on that data in the application the email client installed in the cell phone or tablet will probably be opened.



Step 2: Create the Customer and Company transactions
Note
: Create them exactly as shown on the guide, especially the data type. You will be tempted to create them by default in order to advance quickly to the testing stage, but in this case the new features will not be available because the new domains are used.
Just like in Evolution 1, writing the name of a domain in the attribute name automatically assigns it that data type.




 
 
Step 3: Apply the “Work With for Smart Devices” pattern
This involves the presentation and configuration of the new pattern.
Wysiwyg is the new feature that allows us to view the user interface at design time, and everything that we do is immediately reflected in our screen.
Select both transactions with Control or Shift, right-click, Apply Pattern and select the new pattern.

Next, go to each transaction and in the "Patterns" tab choose "Work With for Smart Devices". Above to the left is the combo to choose the type of device, and in this case select "Android". You may want to try other devices to see how their skins change.

Please check the guide to find the things I'm talking about.

Do not forget to save; the title in the pattern tab must be underlined, which indicates that the pattern has been applied.

In this moment, every time that you save or reopen the pattern you will see that iPad is selected; maybe it is an error.

Note: Be careful if the focus is left on the type of device, because if you click anywhere on the pattern's screen and scroll, the type of device will change.

Below this pattern there are two tabs labeled Instance Data and Documentation.

The “Instance Data” tab has two vertical tabs, “Devices” and “Tree”, which are the pattern views. In the Devices tab we can see how the application will look like and from it we can manage attributes, filters, orders and the view option. From "Tree" we can see the configuration options and change them, for example, by adding or removing attributes, changing the order in which they are displayed, and so on.
In the right-side panel the view of the selected record is displayed and the attributes to be shown can be selected with the buttons labeled “Add attribute” and “Remove”.

Note: These buttons are displayed at the bottom of the grid, so if you don’t see them please use the side scroll bar in the same right-side panel.

In the left-side panel you can add filters and orders for the Work With simply by clicking on "Filters" or "Orders".

The grid has been designed for three attributes: the grey button, a main attribute and a secondary attribute. You can click on each one of them and the dialog box to select attributes in order to change them will be displayed.

In the design view, clicking on the Insert, Update and Delete buttons causes these actions to be enabled and disabled. To give it a try, go to the Tree view to see how they change. When I started this tutorial I hadn’t discovered that; I wasn't sure about it so I sent a question to the forum and they explained me how it works, and that’s why I insist on reading the forum's emails.
 
Step 4:  Create a Dashboard
According to the guide it’s like a menu that can be used to call the objects that have just been created.
Simply create the object and add the options; the name of the option is automatically changed upon selecting the object in the Data property.



Step 5 and 6: Build the application with F5 and run it; they are done at the same time for your convenience
If you didn't fix the data source when you created the KB, a dialog box will be displayed prompting you for the data. If you have checked the Preferences view, you may have noticed that a new generator, Smart Devices, has been added. There you have to add the name of the folder where you installed the SDK; “Android SDK Directory” is the same one that is requested in the F5 dialog box.

First we are asked to create the database and then the application is built. The browser is opened and the Web application with Ruby is displayed to load Companies and Customers; also, a DOS window is opened with Webrick, which is Ruby's web server and Android's emulator to run the application.

Note: When running Webrick for the first time, the Windows firewall may be triggered. In this case you only have to authorize it and continue
.
Note: When the Android emulator is executed for the first time, a message may be displayed with the "Force close" or "Wait" options; this means that it is opening system elements and our application is taking some time to start, so choose Wait and it will appear shortly. This will happen every time you reopen the emulator.

Note: Upon pressing F5, in the Output you may find a message that reads "Run Developer Menu Failed". Don‘t worry about it, it works anyway.




Tricks: Do not close the emulator while rebuilding the application. This is much easier than in Tomcat, which has to be started and closed very frequently. Do not close Webrick either, as all this saves time.
I hope this has been useful in your first steps with Evolution 2 generating for Smart Devices!

* http://gugmontevideo.wordpress.com/2010/11/03/my-first-android-application-o-mejor-dicho-comenzando-con-la-evo-2/
 
Related
Making ideas happen, together :: Important announcements for the Community regarding technology for smart devices
GeneXus X Evolution 2 Beta released!
Smart Devices Generator for Android, BlackBerry, iOS :: By Gastón Milano, GeneXus Architect
Smart Devices at the XXGX
The Android fever :: Post by Cristhian Gómez about his experience using the platform
“I was amazed by GeneXus X Evolution 2” :: Post by Gabriel Medina about Beta 1
BlackBerry, another key element of the GeneXus Smart Devices generator
Welcome 2011! The beginning of a new decade brings with it GeneXus X Evolution 2
User Controls for Smart Devices
South American Soccer Cup 2011, business benefits, and control of personal finances. What do they have in common?
South American Playoffs: follow them in your iPhone, iPod or iPad
Special Edition #GeneXusTheBestOf2014 :: Cloud Computing, the Internet of Things, GeneXus X Evolution 3, Success Stories, Smart Devices and ... Much More!
Release of U2 of GeneXus Evolution 3
Chopo Mobile introduces successful app in Mexico, developed with GeneXus and used for medical studies
GeneXus™ ERP Explorer and Connector for SAP® ERP Now Live on SAP Store