Saturday, June 23, 2012

Issue installing Packages from Android SDK Manager

I was interested in testing my android application using different packages and tools that is available from the Android SDK Manager. I clicked the SDK Manager and I was presented with the tools/packages already installed in my system as well as those that are not installed into my system.

I selected the packages, accepted the licensing of the package and clicked the “Install (x) Packages…” button. The download started but after few seconds I noticed that the download and installation of the selected package was not successful and I got the “Connection reset” message in the log window. I wasn’t sure what could be the issue but I was able browse the internet.

After having googled about this issue, my colleague recommended to try the installation on another machine. I tried in one my colleague’s machine and saw that the download of the package and the installation succeeded. Next what I did is copied all these packages from the my colleagues system under the folder: <android-sdk-directory>/add-ons and copied to my system’s <android-sdk-directory>/add-ons directory. Then I restarted my Eclipse studio and opened the SDK Manager. I noticed all these packages marked as installed.
Hope this helps someone solve this type of issue…

Thursday, June 21, 2012

Eclipse TFS Plugin Source control issue

At times when working with Team explorer, connecting to TFS Server from Eclipse studio can be a painful experience. Assume that you are working in a project and the source code is controlled from TFS server. Every changes are checked id and you are good for the day.

Next day you open the Eclipse studio ready to work on your project and notice that your project is not getting connected to TFS server (though all internet connectivity and your TFS server is up). You notice from the “Team” menu (right click your project to find this menu) that all command of TFS are disabled but “Return online…”. Clicking “Return online…” You will notice a window shows up displaying progress trying to connect to TFS server to associate source control binding to your project but fails in the first attempt but still continues and then displays the projects you have permission on. You select the project from the list of projects displayed and click the Finish button believing your project would now be associated but still no luck. You will find that all commands are still disabled under “Team” menu except “Return online…”. Annoying huh…

In this situation we can notice that if we double click the source control from the Team Explorer window, nothing will show up in the Source Control Explorer window…arrrr

We can try cleaning the project, restarting the eclipse studio, etc.., but nothing helps and we continue to face this issue and the Team Explorer will continue its struggle trying to connect to the TFS Server.

Ok so what’s the solution then…well...In this situation, instead of spending more time researching on this issue, we can perform the following actions to restore source code binding with TFS:

1.       Delete the project (remove only) from eclipse studio (Important Note: Not physical delete of the project from the system)
2.       Restart Eclipse studio and connect to TFS server. This time you will notice that it connects successfully without any issues.
3.       From the Source Control Explorer, right click on your project and click Import… button.
4.       Provide appropriate details in the “Import Project from Team Foundation Server” wizard and…

Things are back to normal….
Hope this help you solve your problem…

Saturday, June 16, 2012

Debugging Android Application directly from Android Mobile

We develop the android application and 75% of the time test using android simulator and witness the application working perfectly all right. We are happy and deploy the application to our android mobile (same target platform) and test verify. 90 to 95% of the time we see the application working alright with the actual device but sometimes we face issues.

What do we do next…we check back the application in simulator atleast once following the same scenario and see if we are able to replicate the issue. We see that the application works just fine in the same scenario in case of the simulator.

OK what next…what are our options…Well we have different mechanism to troubleshoot and the popular amongst those are as follows:

1.       Write to the log and then work through the application in the device with the same scenario reproducing the issue and then pull the log from the device and identify and solve the issue.
Yes but this type of troubleshooting is less preferable if the owner of the mobile is our pocket!!! This type of troubleshooting is more suitable when the user of our application lives in remote location.

2.       From the eclipse studio start debugging the application directly from the android device.
This is one of the easiest way to quickly troubleshoot and fix if we are facing the issue only when executing the application in the android mobile.

Ok…but how…well here is how you do this…

1.       From the Eclipse studio, pull open the “Windows” menu and select “Android SDK Manager” to view the list of target platform, additional libraries and Devices installed and/or available.

2.       From this list, expand the “Extras” folder and make sure “Google USB Driver” is installed as shown below in the screenshot. If this is not installed, then check mark the “Google USB Driver” and get this installed. Note: If any updates are available to the packages already installed, then they are selected by default. It is upto us if we want those updates or not.

3.       On your phone, click Settings > Applications > Development and make sure USB Debugging is on.

4.       After installing the “Google USB Driver”, connect the device to the system using the USB cable. A window opens up and prompt about installing drivers. Wait for it to complete.

5.       Open the command prompt window and navigate to the “platform-tools” directory under android-sdk directory. In my case it was (D:\Program Files\Android\android-sdk-windows\platform-tools)

6.       Type “adb devices” in the command prompt and this will list the devices installed. From this list you should see a serial number (some sequence of digits) and this happens to be the serial number of your android mobile. If you see so, then you are set to go.

7.       Now, instead of following the regular way of executing/running the application, this time it will be different. Right click on your project and from the context menu select Run As > Run Configurations…

8.       From the “Run Configurations” window, click the “Target” tab and select the “Manual” option from the “Deployment Target Selection Mode” panel as shown below

9.       Now click the “Run” button from the “Run Configurations” window and you will be prompted with the “Android Device Chooser” window.

10.   From the “Android Device Chooser” window, select “Choose a running Android device” option and then select the serial number (this will match with the serial number that displayed in the command window) and click the “OK” button.

11.   This time the application (apk file) is loaded directly in the android mobile and you can follow the same mechanism to debug it (Setting breakpoints and so on)

Hope this helps troubleshooting your issue…

Happy Androiding…

Saturday, June 09, 2012

Simulating an Incoming Call in the Android Simulator

At times, when developing the application or after developing the application, we are interested to test and break our application with all possible ways we can so that end users don’t end up facing such issues. One such scenario that we possibly miss out while testing our application using simulator is when a call arrives and our application is active.

This scenario is easy to simulate in the android simulator and this is done as follows:

1.       Start the Android Simulator and we can notice the number that is displayed on the title bar (as showing using the arrow mark in the screenshot below). In this case it is 5554.

2.       Open the command prompt window and type the following command to start the telnet session to localhost with port number as the number identified in the above step i.e., 5554

telnet localhost 5554

3.       This will open the telnet command session to the simulator. In this session, we can type help command and this will display all possible actions that we can perform on the simulator.

4.       From the displayed list of commands, we are interested in performing an incoming call to the simulator. The command is gsm and to know the syntax we type the following command:

help gsm

This command will display all sub-commands that can be used as part of gsm operation and they are as follows:

5.       From the above list, we are interested in the gsm call sub-command and this can be issued as follows:

gsm call 9999999999

here we can use any 10 digit number and not less or more. Issuing this command we can see an inbound call in the simulator as shown below:

                This helps us by providing a new level of testing using the android simulator and not depend on android devices in such scenarios.

                Happy Androiding…

Wednesday, June 06, 2012

Eclipse displaying error icon on Android Project

When working with Android Project files, sometimes we work directly from within Eclipse studio and sometimes outside of the studio. Assume that in one our android project, we are in need of one complex functionality to be performed. We Google and get hold of java source that does exactly what we require. So, we go ahead and download the java source file and add it using Eclipse studio to our android project. Having added that we notice a couple of errors in the downloaded java file. Instead of fixing it right away, we decide to fix at a later point of time and close the eclipse editor (assuming a long break time).

Returning back we learn that our R & D team have implemented the complex functionality and now we decide to get rid of the downloaded java file. We move to the src folder location using windows explorer and delete the file. (Note that this file was added using the eclipse studio and on top of that the downloaded file had errors). Now we open the eclipse studio and notice that there are no error icons displayed for any files but the android project.

We try the following ways to get rid of the error but all goes in vain:
1. Clean the project but still the error remains
2. Refresh the project but still the error remains
3. Fix Project Properties from Android Tools but still the error remains

The fix that worked in our case is removing the .metadata folder from the project root location. This folder seems to hold reference to all the files added using eclipse studio.

Friday, June 01, 2012

Android ~ Facebook login issue from Android application

When developing android applications that uses Facebook’s LoginButton to authenticate and authroize, there will be no issues running on the emulator. But when the same apk file (android installation file) is installed in an android device and executed it won’t work. The Facebook’s LoginButton, after clicking, progresses a while and returns back to the same screen taking us nowhere.

There could be several reasons for this behaviour but I have came across a couple of symptoms and was successful in addressing those:

1.       You might have not set the hashkey for your application in facebook or you might have messed up/changed your working android debug.keystore file locally in your system.

If you have not yet set the hashkey for your application, please generate hashkey for your application first, then set the hashkey for the facebook application. Here is the article that explains in a step by step manner to create your hashkey:

At times when working with our android application we may sometimes use other’s debug.keystore file and replace our’s to see if some of our issues go away. Now if we generate the apk file and install in the device to test it out, we will notice this issue. To resolve we will have to re-generate hashkey and set that in the facebook apps.
2.       You might have missed the invocation of super method in the protected void onActivityResult(int requestCode, int resultCode, Intent data) method block

If you have missed, then add the following as the first line in your method block:
super.onActivityResult(requestCode, resultCode, data);

Edit: There is one another problem that I dealt with the signed apk file. I used the following steps to sign the apk file:
Right Click on the Project -> Android Tools -> Export Signed Application Package...
I provided the project name and clicked next and selected the keystore location path that has an empty space in it. Having generated the keystore file, signed apk file, generated the hashkey using the keystore file and setting it to facebook app settings page I was seeing that I was not able to get past the login screen. I was seeing a facebook progress dialog and after few seconds it disappears. I was running out of clues as what could be missing. Later along with my colleague, went thru the same process of generating the keystore and all that but this time without an empty space character in the path. We ran the apk file and tried the facebook signon and bingo. It worked!!!

Hope this helps you to resolve your problem and importantly save some time…

Happy Androiding