Monday, February 24, 2014

My Android SDK and ADT Upgrade Experience

My last experiments with Android development was when I bought my first Android smart phone. Don't confuse by the word first smart phone, still I am using the same Galaxy Y. The truth is that after those days, I didn't get much time to play around due to various reasons such as busy with other technology stuff such as Big Data, Hadoop and project releases in Office. But recently I got a chance to do some research activities in Android phone. So started Eclipse again.

The research requires reading the calendar to get meeting details. The initial code base was set-up by one of my colleague and I am supposed to start from a zip file which he sent to me.He actually got the Zip from another one who left the company. The first challenge was how to check in the code into a repository. As our company mainly focus on the Microsoft technologies, we are using TFS. So downloaded and installed the TFS plugin for Eclipse. Things worked straight there. Then thought of compiling the project and here begins the story of upgrading Android development environment.


Since the calendar contact APIs are introduced in API Level 14, I had to have an environment which supports API Level 14. Mine was API Level 10 which is enough for developing apps for my Galaxy Y which uses 2.3.3 GingerBread. Things seemed straight as its the matter of upgrading the API levels. Opened the Android SDK manager but I was not able to find the API Level 14 to install. The installation starts from here.

Installing ADT

As all the developers know ADT is the Eclipse plug in for Android development. It provides the development support. My current ADT version doesn't support the API Level 14. So I started to install ADT 22.3.0. The first error started from here.The error was as follows

"A folder failed to be renamed or moved. On Windows this typically means that a program Is using that Folder (for example Windows Explorer or your anti-virus software.) Please momentarily deactivate your anti-virus software. Please also close any running programs that may be accessing the directory '..\android-sdk-dir\android-sdk_r12-windows\android-sdk-windows\tools'. When ready, press YES to try again."

If we look at the logs we can easily understand that the installer is trying to rename the tools folder to temp\ToolPackage.old01.Below is the log.

"Failed to rename directory ..\android-sdk-windows\tools to ..\android-sdk-windows\temp\ToolPackage.old01.

Done. Nothing was installed."

The google gave a bunch of ideas such as disabling antivirus which I never can do in my company machine, giving permissions,  renaming or moving some folders, killing some particular processes etc...Somebody even went to the extend of editing the install file. I did almost all the things except editing the install file. Since these methods are not helping, decided to setup the ADT from beginning.

It was smooth. I downloaded the SDK and extracted to new folder.Then changed the SDK path in the Eclipse and was able to install ADT and required API Levels. But when I run the application it got ended by the below message in the console window.

Upgrading All Android development supporting tools.

"Connection with adb was interrupted. 0 attempts have been made to reconnect. You may want to manually restart adb from the Devices view."

This tells more like a restart request. I tried restarting the simulator and Eclipse 2-3 times without any luck. Most of the links were talking about this issue in a USB debugging scenario. Since I am not using the USB debugging these things felt not applicable to me. Then thought of restarting the machine. But before restarting the machine decided to google once again with 'upgrade ADT' keyword in search. It gave one more SO link where says to upgrade everything when we upgrade ADT. I followed the same way and it got fixed.

Another error I got during this exercise was
"An internal error occurred during: "Launching com.myproject".
com.android.ddmlib.IDevice.installRemotePackage(Ljava/lange/String;Z[Ljava/lang/String;)Ljava/lang/String;

This also resolved when I installed everything fresh. The Eclipse tools which I upgraded are
Traceview, Hierarchy viewer, Android Development ToolKit & Dalvik Debug Monitor Service( DDMS)

Then I successfully executed the project which my colleague gave me and checked the source into TFS.

Changing the target in project.properties file

Then I thought of running my previous Android projects as those were my first study apps. But unfortunately they failed with below exception

[DateTime - Dex Loader] Unable to execute dex: java.nio.BufferOverflowException. Check the Eclipse log for stack trace.
[DateTime - Test] Conversion to Dalvik format failed: Unable to execute dex: java.nio.BufferOverflowException. Check the Eclipse log for stack trace.

Again googled. This time I was able to study about one more file called project properties. Since I have changed the build tools, I need to update this file to point to version 19. I changed the target from android-10 to android-19 and every project started working.

This might be familiar to the regular Android developers. But for developers like me who works mainly in other technologies, its a task.

2 comments:

Blogger said...

I have been using Kaspersky antivirus for a number of years, and I'd recommend this product to everyone.

Blogger said...

If you want your ex-girlfriend or ex-boyfriend to come crawling back to you on their knees (even if they're dating somebody else now) you must watch this video
right away...

(VIDEO) Win your ex back with TEXT messages?