Here, I’m trying to help those of you who are stepping into the Android world for the first time.
And I’d like to encourage you: it is easy and a lot of fun.
(However, you might get some headache here and there – but that’s life…)
When I did my first try with Android, I found it quite confusing.
So I’ll try to give short and structured instructions in this document.
I guess that you’ll visit the Android homepage in order to follow the tutorials there. So you’ll find answers and detailed documentation there, which are missing here.
At the end of this document I’ve collected some tips that I found useful.
This document is related to the Prerequisites-document for the GWPA tutorials
The reason why it is located in the SAP NetWeaver Gateway Space is that many users who are stepping into the Android world are doing that because they’re trying the Starter Application Wizard that is provided within NetWeaver Gateway Productivity Accelerator (GWPA). This was as well my personal reason…;-)
Note: you don’t need a real Android device (== the actual telephone – or better: smartphone or tablet) to start with Android development, because there’s an emulator. So you can safely go ahead, follow this document, and then follow the tutorials on SCN which explain the Starter Application Wizard of GWPA.
1. Prerequisites for Android environment
Yes, even the prerequisite itself needs some prerequisites…
1. Java is required for writing and running Android applications
2. Eclipse is required as development environment.
Why Eclipse? Because there are Android-specific plug-ins available for Eclipse.
Of course, pure Android development is possible with any other IDE, or even without IDE.
It is possible to run and manage the Android emulator from the command line.
Anyway, it is much more comfortable to use Eclipse and the Android tools in Eclipse.
In this document the usage of Eclipse is described.
Regarding both prerequisites, Java and Eclipse, please refer to my general document here http://scn.sap.com/docs/DOC-52235
2. Install Android Platform
The Android Platform is also referred to as Android SDK Manager, aka SDK tools
1. When developing an Android application, you have to think about:
which version of Android should be supported by your app.
If you don’t need the newest features, your app will run on newer and on older devices.
In order to achieve this, you need the ability to develop against different versions of the API.
And you need the ability to test your developed app against different versions of the API.
This is nicely supported by Android by using the SDK Manager.
The SDK Manager is the empty platform that manages the SDKs.
It helps you to download and manage all existing Android SDK-versions.
2. When developing an app, you also want to test it and run it.
This is done by creating and using an emulator.
The emulator is then configured with the desired downloaded SDK.
An example for a development scenario:
You download SDK version 4.3 using SDK Manager.
You develop an application against it.
You create a virtual device based on 4.3 and run it on the emulator
You test your application using the emulator based on 4.3
You download SDK version 3.2 using SDK Manager.
You create a second virtual device based on 3.2
You test your application using the emulator based on 3.2
You proceed similarly with more SDK versions
How to install the platform?
Open the Android development homepage at http://developer.android.com
Click: “Get the Android SDK” on the bottom.
Click: “Use an existing IDE” on the bottom.
Click: “Download SDK tools for Windows” in the expanded section, then confirm and download.
After unzipping the downloaded archive or running the downloaded installer (depending on the version of the platform), you have the following new folders on your file system:
If you have a look into the folder “platforms” you’ll see that it is initially empty.
This folder will be filled with the SDKs that you download in the next step.
Now start the SDK Manager via double-click on “SDK Manager.exe”
You might have to configure a proxy in the SDK Manager tool, such that it can access the internet in order to download the SDK packages.
This is done as follows:
Start the SDK Manager and open the Menu “Tools -> Options”
Enter the proxy host and port
3. Install Android SDK version(s)
As described above, after installing the platform, you need to download at least one SDK.
Start the SDK Manager.
The tool displays a list of so-called “packages”.
1. All existing (supported) Android SDK versions
2. The folder “Tools”
3. The folder “Extras”
You need to select what you want to download
1. An actual SDK, e.g. Android 4.4.2 (API 19),
It makes sense to check all sub folders
(although you may skip the samples, the sources, and similar, if you don’t need them)
2. Apart from the SDK itself, some additional packages need to be downloaded:
SDK Tools, Platform-tools and Build-Tools.
Note: Don’t forget to install the Build-Tools
(otherwise the generation of java objects out of xml description will not work) !
3. Within the “Extras” folder, there are packages which make sense to download as well:
4. Create AVD
The used terms in this context:
AVD == Android Virtual Device == the Emulator
In order to create an AVD start AVD Manager.exe (can be found beneath the SDK Manager.exe) and press “New”.
For the required settings, see the screenshot below.
For convenience, templates for real devices are available.
After creating an AVD, it can be started right from the AVD Manager.
Press “Start” in AVD Manager.
It takes long, long time until the emulator is up and running – so don’t worry.
Once it is running you’ll recognize it – it looks just like a real device.
You have to unlock the screen and then you can play around, e.g. open apps, like the Internet Browser.
It may be necessary to enter proxy settings in the emulator, if your app requires it (see tips&tips section below)
5. Install ADT
ADT stands for ADT==Android Development Tools for Eclipse
Basically, even without installing ADT, you’re already prepared for developing Android apps.
But if you use Eclipse, it makes sense to install the Android plug-ins for Eclipse, the ADT.
If you’re new to Eclipse, you can read my introduction here: Getting started with GWPA: Eclipse Preparation
Within Eclipse, enter the update site from where the ADT can be installed:
(“Help -> Install new software -> Work with”)
Select all features, excluding the NDK.
Open the Android Preference page: “Window -> Preferences -> Android”
Check that “SDK Location” points to the root folder of the downloaded Platform.
The list of SDK Targets should show all downloaded SDKs (e.g. Android 4.4.2 API 19).
The ADT offer useful development tools.
– Wizard: “File->New -> Project -> Android -> Android Application Project”
– Logging: “Window-> Show View -> other -> Android -> LogCat
– Perspective: “Window -> Open Perspective -> Other -> DDMS
– Editor: a graphical editor for creating UIs
6.Create Android Application
1. First variant: Write your Hello World App
Of course, the typical very first application is always the Hello World example.
Of course, I don’t discourage to do it.
There are lots of interesting and good tutorials on the Android website:
Click “Develop” on the top.
Click “Training” on the top left.
Click e.g. “Building your first app”.
2. Second variant: Let a generator do the job
After having said your hello to the world, you can use a code generator to create an Android application.
If you have access to an OData Service, you can use the application-generation tool offered by GWPA (SAP NetWeaver Gateway Productivity Accelerator).
Firstly: yes, you need access to an OData Service.
If you do not have access to one, then you only have to quickly register and then use a Sample Gateway Service
Find the relevant information here http://scn.sap.com/docs/DOC-40986
Secondly: yes, you can easily install GWPA (Gateway Productivity Accelerator)
You only have to enter the update site URL in your Eclipse
Find the relevant information here http://scn.sap.com/docs/DOC-52235
Thirdly: yes,the generation of an Android Application is easy and it is described in SCN
You only have to step through a Starter Application Wizard
Find a description here
3. Third variant: use sample applications
Android provides sample apps that can be imported in Eclipse
Proceed as follows:
In Eclipse, go to
main menu -> File -> New -> Other -> Android -> Android Sample Project
In the subsequent wizard page, choose the SDK (API version) for which you wish to view the existing sample apps
Then choose a sample app and press Finish
After the wizard is done, you’ll see a new project in the Eclipse Project Explorer view.
You can look through the sources and run the app in the emulator.
Emulator: Configure Proxy
Start your Android Emulator -> Apps -> Settings (need to slide to right) -> More -> Mobile networks -> Access Point Names -> TelKila
Then enter the settings for Proxy and Port
Emulator: Remove apps
Deleting apps from the emulator can be done in the DDMS perspective:
select apk in File explorer at data/app,
then press the red minus-button
Emulator: wipe data
When launching the emulator from the AVD Manager, it is possible to select the option “wipe user data”
Emulator: using keyboard
Using real device
You’ll most probably want to test your app on a real device (smartphone or tablet).
Basically, the procedure is the same as when using the emulator.
But you have to do the following preparation steps:
1. Download, install and configure the driver for your device (under Windows)
2. Enable USB debugging on the device.
The description can be found here: http://developer.android.com/training/basics/firstapp/running-app.html
Some details here.
Troubleshooting real device
You’ll most probably want to see the log output when testing on real device.
Therefore, you have to connect the device to your PC via USB cable.
As usual, don’t forget to enable USB debugging on your phone (you might need to google for how to do that)
Open a console window and increase the size of the console window.
Enter the following command:
adb -d logcat
Now test your application. You’ll see the log output in the console.
As usual, in order to execute the adb command, you have to either navigate to the folder platform-tools, or specify the full path in the command
See here for the list of commands: http://developer.android.com/tools/help/adb.html#commandsummary
Eclipse: build error “R cannot be resolved to a variable”
After generating Android App, you get a build error “R cannot be resolved to a variable”
Reason: Build tool for Android is missing,
Solution: install “Android SDK Build Tools” in SDK Manager
Eclipse: logs cannot be seen
Bring the Eclipse “Console” – View to front.
in “Console” – View, open the relevant console via drop-down-arrow
Eclipse: Android logs cannot be seen in log cat
Try this: switch to DDMS perspective -> select the emulator then remove the filter.
In worst case: restart Eclipse
Eclipse: start SDK Manager from Eclipse
If you’re working with Eclipse, you don’t need to change to file system for starting the SDK Manager or AVD Manager.
The relevant menu entries in Eclipse are located at the Main menu bar -> Window -> Android SDK Manager
Note: these menu entries are only available if the Java-Perspective is active (Window -> Open Perspective -> other -> Java)
Eclipse: enable to get prompted for selection of emulator when launching a project
If there are more than one AVDs available, it makes sense to get a selection-dialog prior to launching an Android project in Eclipse.
This is configured as follows
Select the Android project.
Choose Run -> Run Configurations
Select your launch Config or create a new one
Select Tab “Target”
Select “Always prompt to pick device”
Eclipse: cannot start the Android SDK Manager from Eclipse
In Eclipse, there are menu entries that are specific to Android
They can be reached at Eclipse main menu -> Window
But they are only available in the menu, if the Java-Perspective is active
Otherwise you don’t see them.
In order to activate the Java-Perspective: Window -> Open Perspective -> Other -> Java
Eclipse: attach Android sources
First download the sources: Go to Window->Android SDK Manager and install “Sources for Android SDK”.
If you now try to click the hyperlink of an Android class, you get the “no source attached” message.
Click “Attach Source” then select an external folder.
Browse to the location where your SDK is installed, e.g. /home/me/android-sdks/sources/android-16
Error in Eclipse console: “An established connection was aborted by the software in your host machine”
The reason could be that there are 2 instances of Eclipse running (with Android development)
The solution could be to restart Eclipse
and/or restart ADB
The command on the command line would be:
GWPA Starter App Wizard: cannot see downloaded SDK
You’ve installed Android and downloaded SDKs (with SDK Manager)
You’ve opened Eclipse, have gone to the Android Preference Page (Window -> Preferences -> Android) and have verified: the SDKs are in the list.
Later, you’ve downloaded another SDK, have again gone to the Android Preference Page, but you haven’t seen it added to the list of Target SDKs.
You’ve wondered if you’ve done anything wrong. But you haven’t.
The solution is: you need to reload the list of SDKs, by pressing “Apply” (in the Android Preference Page)
GWPA: cannot view Attachments in generated Workflow Application
The AVD needs to be configured with an SD card, otherwise it won’t be possible to view Attachments in a generated Workflow Starter Application.
See screenshot above.
GWPA: Gateway connections and services cache
Users of GWPA know that preference page where connections to SAP backends can be defined.
When using the “Catalog” (provided by GWPA) for browsing Gateway-services, the complete list of services has to be fetched from the backend.
Furthermore, the metadata of each service has to be requested from the backend and has to be parsed in order to show the details of the service.
Since there can be many services, it is necessary to use a caching mechanism, in order to avoid that too many calls are fired too often towards the backend.
Interesting to know: The location of the cache.
It is (under Win 7):
For each connection, there’s one folder, following certain naming-rules:
Inside the folder, there are 2 files for each service that is found on the backend:
First file for the service document.
Second file for the metadata document.
Inside each file you can find the content of these documents.
If the service data could not be read, either due to network issues or due to erroneous service implementation, the suffix _failure is appended to the file.
Depending on the reason, you might find useful information if you open such …_failure file
If you face strange errors wrt the service that you want to consume or if the service is marked as erroneous and you think it shouldn’t, you can try to reload the service from the Catalog View (there’s a Reload button on the Catalog UI)
Sometimes, this doesn’t help, as it doesn’t reload properly.
So the last and easy solution is always to delete the cache.
This means: delete all the files in the sap-data-storage folder.
Of course, it would be enough to only delete the 2 files related to the corresponding service.
GWPA: language issues in generated Android app
Please refer to this blog post: How to solve language issues in Android app, generated by GWPA