You are currently browsing the category archive for the ‘Android General’ category.

This is in continuation to the first two articles of Android Google Maps Api Ver 2.0.

The objective of this article is to test our Google Maps Api Ver 2.0 Application that we have developed so far in the first two parts of this series of articles on a Physical Device. We need a physical Android device. The one that I have is HTC One X.



Identifying which  Android USB drivers to use

Before we start to install the drivers we need to identify which drivers are we going to install.If we have an Android Developer Phone (ADP) like Nexus we will use the Google USB Drivers.  The latest Google USB Drivers can be downloaded using the following link. and help on how to install it . Only the Galaxy Nexus drivers are provided by Samsung and not Google. We can get the drivers for Galaxy Nexus from the following link. . If we have a device other then the above mentioned, we will use OEM Drivers. I own an HTC ONE X so in this article we will go the the OEM Drivers.

Installing the Android USB Drivers

Now that we have identified which device do we have and which drivers we will install. In my case I ll install the OEM drivers for HTC ONE X. The link shows a list of devices and their links from where their USB drivers can be downloaded. . So we will go to the HTC page and will click on support to get the drivers. HTC Sync Manager will do the job.  When the appropriate drivers are installed on the computer than  we will move to the next phase.

Setting up Eclipse for our Physical Device

Run Eclipse,  open the DDMS tab. If our emulator is running we will only see the emulator in DDMS. We wont see Physical Device in DDMS.

DDMS not showing the Physical Device

DDMS not showing the Physical Device

Enable the USB debugging from the device. Then in DDMS select the Devices Tab and click on the right most arrow to get the drop down menu , click on Rest adb.

Resetting the adb.

Resetting the adb.

When we Reset the adb, the DDMS will show our Physical Device in the Devices Tab. If not make sure that the device is properly connect to the computer with the USB connecting cable.  This is what you will see when everything goes fine.

DDMS showing our Physical Device in the Devices Tab.

DDMS showing our Physical Device in the Devices Tab.

Deploying our application on the Physical device.

Close all the Emulators, Make sure the Device is connected properly with the computer. In DDMS check in the Devices Tab if its still showing our Physical Device, if it is than its ok, if not then Reset adb as explained earlier. After having the Physical Device in the DDMS go to Run Configuration Screen from where we normally select the AVD or emulator to Run our application. The image below shows the screen.

Deploying our Applicaiton on device.

Deploying our Applicaiton on device.

In the Target Tab click on the dropdown menu, it has three options

  1. Active AVD’s/Active Devices
  2. Active AVD’s
  3. Active Devices

Select the 3rd option, “Active devices” Then Click Apply and Run. If the device is properly connected, and it appears in the DDMS, the system will automatically search for active devices. In our case HTC One X is the active device. The application will be directly deployed on our Device.  When we make some changes to the code, we can deploy the application directly to the device exactly the same way again, but its better to un install the last deployed application and then deploy a fresh copy of our application again on the device from Eclipse.

Note:- This article is not specific for deploying just Google maps applications on Physical Devices. Any application can be deployed on Physical Device using the steps in this article. Secondly , earlier it was not possible to run Android Google Maps APi ver 2.0 on AVD or emulator so we had to test the application on Physical Device. But now its not necessary , now we can test our Android Google Maps API Ver 2.0  applications on emulators or AVDs.

Thats all for now, I ll come up with testing and deployment on emulator soon

Learning Android Canvas

My First Book
My First Book

I was away from my blog for a few months and the reason was this book. It was a challenging task and a lot different then writing my usual technical articles.  On 10th Dec 2013 I received the first printed version of my book. I really don’t have words to explain my feeling when I opened the package and saw my name on the Title of the book.

For Details follow the link

There are tons of articles on the internet that demonstrates how to call a web service from android code. I ll try to keep it simple so that my reader don’t get confused as i was while reading others articles on the current topic. Object of this article is a  simple application that takes text from an Android Activity, than calls a web service, pass the values to the web service, than the web service do what ever it likes to do with the received text and that’s it. When we are done with this scenario than we will make this application more complicated by receiving something from a web service as a response and do something inside our application.

I ll assume that we have a web service developed and deployed for this purpose. For this tutorial we will use the web service that i have previously developed which receives two numbers and returns their sum.

Start with a simple application. Than download the latest KSoap2 jar files from the following address.

or you can search the KSoap2 library and download it from any other location. The thing to remember is that what ever is downloaded it should be ksoap2-android-something and not just ksoap2-something.  When the jar file is downloaded. Add the jar file to the existing project. Steps are given below.

  1. Right click the project and click Properties.
  2. From the opened dialog click on Java Build Path
  3. Open the Libraries Tab
  4. Click on the Add External JARs button to the right.
  5. Select the ksoap2-android-something.jar file from the HDD and click ok.

Ksoap2 jar file addition to the application

This will add the library to the current application. now coming to some coding thingi. Add the following in the import section

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;

Application that calls a web service and and sends two numbers

Add the following code to the start of our Main Activity code, outside the onCreate() method in the section where we define our global variables.

private final String SOAP_NAMESPACE = "";
private final String SOAP_URL = "";

private final String SOAP_ACTION = "";

private final String SOAP_METHOD_NAME = "add";
 private SoapObject request;
 private PropertyInfo pi1;

private PropertyInfo pi2;

In the above section we have created variables with values providing the Namespace, the URL where our web service is hosted, the action consisting our WEB METHOD in our web service and the method name that will be called. Other than that we have created two objects of type SoapObject and PropertyInfo.

//webservice thingi start

request = new SoapObject(SOAP_NAMESPACE, SOAP_METHOD_NAME);

pi1 = new PropertyInfo();
 pi1.setValue(etno1.getText().toString());//get the string that is to be sent to the web service

pi2 = new PropertyInfo();
 pi2.setValue(etno2.getText().toString());//get the string that is to be sent to the web service

SoapSerializationEnvelope envp = new SoapSerializationEnvelope(SoapEnvelope.VER11);
 envp.dotNet = true;
 HttpTransportSE androidHttpTransport = new HttpTransportSE(SOAP_URL);
 try {, envp);
response = (SoapPrimitive)envp.getResponse();
 } catch (Exception e) {
Log.i("WS Error->",e.toString());
 //webservice thingi ends

In the above code we define a request object, than we define a Property Info object, set a name for it. Assign a value to it. Set its type and add that property to the already created request object.  After that “, envp);” this is the actual statement that actually calls the web service and passes the values to it. If everything is fine, the program will execute smoothly else the program will crash here.

Issues that am unable to solve so far.

There are a number of possibilities that can cause the application to crash at this point. “response = (SoapPrimitive)envp.getResponse();” this will get the response from the web service if the web service is actually returning some value. So far am trying to tune this part. As the response is not giving me the desired returned value. Either it returns a zero, if i switch between SoapPrimitive and SoapObject than either the program crashes or returns the value the i pass first to the web service.

Note:- KSOAP2 might not be a good option if this return value issue is not solved but if we are working with a web service that only receives a value from our Android application and do something of its own like saving the received string in the database on some server, than KSOAP2 can be used as explained in the above tutorial.


To use Google Maps in Android using MapView Control we need Google Maps API Key. To get the key we have to go through the following steps.

  1. Locate debug.keystore file on your system.
  2. Locate keytool.exe file on your system
  3. Generate MD5 fingerprint.
  4. Use that MD5 fingerprint to get the Google Maps API Key

The debug.keystore file can be found at “c:\users\mir nauman tahir\.android\debug.keystore”

Replace “mir nauman tahir” with your current user name.

Now navigate to keytool.exe file. “c:\program files\java\jdk1.7.0_02\bin\keytool.exe”

Replace the jdk version with the version installed on your system.

Now execute the following command.

C:\Program Files\Java\jdk1.7.0_02\bin>keytool.exe  -list -alias androiddebugkey -keystore “c:\users\mir nauman tahir\.android\debug.keystore” -storepass android -keypass android

If prompted for a password, try “changeit” or just press enter key to enter an empty password. This command will return SHA1 fingerprint. jdk1.7 or higher will return SHA1 by default. Remember the bold and italic text is the path to the debug.keystore…

View original post 187 more words

The reason behind writing this article is that I got a new machine and I was configuring it for Android development. Everything went well but when came to the step for generating the Google Maps API Key, I got stuck when couldn’t find “debug.keystore” file at the desired location inside “.android”  folder.

.android folder without debug.keystore file

If we don’t have debug.keystore file we can’t get Google Maps API Key. To solve this issue and to get the debug.keystore file in the desired location is

  1. Open Eclipse
  2. Start a new Android project
  3. Run the project in any AVD that’s already created.

When the project is successfully RUN on the Android Virtual Device. Now go to your “.android” folder and check. You will see that the “debug.keystore” is present there.

.android folder with debug.keystore


By default the “debug.keystore” file is not created in “.android” folder. When we successfully build our first project, the “debug.keystore” file is automatically created in “.android” folder.

Now we can use it to generate our Google Maps API Key.

Related Article


I updated my Android SDK, downloaded the new packages, everything went pretty well. Than i started a test android project. When i tried to RUN it, the Android Virtual Device (AVD) gave me this error.

invalid command-line parameter: AND
Hint: use '@foo' to launch a virtual device named 'foo'.
please use -help for more information

Starting AVD Error (invalid command-line parameter: AND Hint: use '@foo' to launch a virtual device named 'foo'. please use -help for more information)

I tried every possible tweaking to the eclipse configuration and SDK configuration. Tried alot of things with the AVD Manager but nothing worked. Here is wat solved the problem for me. I copied the installed  Android SDK  i.e, android-sdk-windows-1.5_r3 from my g:\(some nested folders)\android-sdk-windows-1.5_r3 to C:\android-sdk-windows-1.5_r3. Than i reconfigured the path in eclipse for android SDK and started the AVD. walah… it worked.

Reason:- There were white spaces in the folder names in the previous path that was creating  the AVD to raise this stupid error. So to solve the problem either u have to remove the white spaces from the path that u r using or u have to move the SDK to the root of some drive and remove white spaces from the folder name of the SDK or u can even u even use the path from the command prompt that removes white spaces and converts the path to a single string using ~ sign. Still if this sounds too complicated we can use one of the first two techniques to solve the problem.

1.Download the recovery image form the link below. Use this image in case of  recovering from a disaster. Recovery Image: from

2. Copy to /source/ directory.

3. Go to ‘vendor/htc/dream’  and run ‘./’, or  ./

4. Then, Then apply the following commands

5. source build/

6. $ lunch aosp_dream_us-eng

7. Compile the modified Android Source Code for the device

8. $ make -j

9. Now the generated files are

10. boot.img,

11. recovery.img,

12. system.img,

13. userdata.img

14.  These files will be located at

15. out/target/product/dream-open/

16.  Put device into FASTBOOT mode

17. reboot

18. power_on the device with BACK key pressed,

19.  It should show the driods on skateboard with fastboot text displayed.

20.  Make sure the cable with the device is connected.

21.  Now apply the following commands

22. sudo su

23. set path to fastboot

24. export PATH=/mydroid/out/host/linux-x86/bin/:$PATH

25.  Stop and start the server

26. adb kill-server

27. adb start-server

28.  Check the fastboot devices

29. #fastboot devices

30.  The above command will show you the fastboot devices.

31. HT94JLZ00002    fastboot

32.  Now apply the following command.

33. #fastboot -p dream-open -w flashall

34.  flashall will apply all the above listed img files one by one. but we can also do that manually by specifying the image file name. After this the flashing will start and our device will be loaded with our own modified source code.

Blog Stats

  • 325,597 hits

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 233 other followers

%d bloggers like this: