Showing posts with label Eclipse. Show all posts
Showing posts with label Eclipse. Show all posts

Monday, March 10, 2014

Not able to start Android application after adding activity through new Wizard in Eclipse

I normally add new Android activities, corresponding classes and config changes manually. Recently I came to visit a link from Kerala start-up village blog where they were explaining how to create new activity in Android. They mentioned in the same way I am doing. Or probably most of the developers are doing. Then I thought of other easy ways using Eclipse IDE or the Android plug-in to generate activity xml, its class and changes in the AndroidManifest and could see Android help page which explains the same. 

Just thought of trying it out by creating an activity into one of my Android project. After creating the activity, I was not able to run the application in simulator. The error got in the Console window is given below .

[time - app name] Installation error: INSTALL_PARSE_FAILED_MANIFEST_MALFORMED
[time - app name] Please check logcat output for more details.
[time - app name] Launch canceled!

It suggests to check the logcat as well. So opened the logcat window and log reads as follows.

<time>: W/ActivityManager(407): No content provider found for permission revoke: file:///data/local/tmp/<name>.apk
<time>: I/PackageManager(407): Copying native libraries to /data/app-lib/vmdl-1401938519
<time>: W/PackageParser(407): /data/app/vmdl-1401938519.tmp (at Binary XML file line #12): <activity> does not have valid android:name

Here the console logs says that the manifest is malformed. In logcat window we could see 2 issues. One error says permission issue. And second line says activity does not have valid android:name property value. It means the activity which I added via the android wizard might have added incorrect entry to the android manifest xml file.

I started by googling the error message. Most of the SO links says its permission issue and I have to give full permission to C:\Users\<user name>\.android folder. I checked and could see it has full permission. Then I compared my faulty project's androidmanifest.xml file with other project and could see that the Android wizard which used to add activity has added the package name to the android:name. Earlier the name was .activityname. The wizard updated the activity name as packagename.activityname which caused the problem. Since the package name is already mentioned in the manifest root node, activity name cannot have the package name.

A sample has been given below

Wrong xml
<activity
            android:name="JoymonOnline.Malayalam.SwipeHost"
            android:label="@string/title_activity_swipe_host" >
</activity>

Corrected the android:name

<activity
            android:name=".SwipeHost"
            android:label="@string/title_activity_swipe_host" >
</activity>

Happy coding. 

Monday, March 3, 2014

Cloud based VisualStudio Online TFS - Some recipes to work with it

I started using Microsoft's FREE cloud based Visual Studio Online TFS when my company's TFS server got crashed and the situation continued for couple of weeks. Since we were doing some research projects, we didn't feel the source is something must be kept in company TFS. Only problem we faced was the number of team members are limited in free TFS Cloud account. But since most of us were not actively participating in the development, we were able to live with 5 people tfs team.

Now the in-house TFS is up and I am in the process of moving the source to company tfs. I moved one project and then thought of deleting it from my personal cloud tfs. Since the TFS online  is new, it was little difficult to find help. Actually its not about finding help. Its about the user experience of Visual Studio online portal. If the user experience is good, the presense of help documents doesn't matter. But it seems the team has done good job in updating MSDN with the help. Since the direct google doesn't give the links, I thought of posting the same here. So below are some common tasks and how it can be done if we are using Visual Studio Online TFS.

Visual Studio Online, TFS Online, Cloud based TFS are all same. If you want can start creating your own team projects by signing into www.VisualStudio.com with your live id.

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.

Monday, June 10, 2013

"The literal Octal 08 (digit 8) of type int is out of range" Java compiler error

This error came when my wife was doing simple programming in Java using Eclipse IDE. She was trying to do 'number to words conversion' where hard coded int input = 8; can be converted to "Eight" but not int input = 08;

It clearly says the compiler is treating this as octal literal .But this is really new to me as I am more working with C# & VB.Net which don't have this feature. After a google we were able to find the list of supported literals in Java.

http://en.wikibooks.org/wiki/Java_Programming/Literals

Leading 0 - Ocatal eg: 010 -> 8
Leaxing 0x - Hex eg: 0xA -> 10
Leading 0B - Binary eg: 0B11 -> 3 (Supported in latest Java versions >=7)

Monday, April 30, 2012

Use actual Android phone instead of Emulator

Every time when I had entered into mobile application development the biggest challenge was how to transfer the application from the emulator development environment to the actual mobile phone. In Windows Phone 7 too moving developed app to phone is little difficult as we need a developer unlocked phone or developer account. But I think it is far more easier than moving an iPhone application from development environment to actual iPhone for testing purpose.

But in Android things are very easy .Just follow the below steps

  • Connect your phone via USB
  • Make sure the USB Debugging is enabled in Settings -> Application Settings -> Development
  • Start the application from Eclipse. It will ask you which device to use. Select your phone.

That's it .Your first Android application is in your Android phone. Even if you disconnect the USB the app will be present in phone. I have my first HelloWorld application in my Samsung Galaxy Y even till now.

My environment is Win 7 32 bit and has the software in the phone CD installed. It worked without any issue. Heard that there may be some issues with drivers and all. So check the below detailed link, if you face any issue in debugging in Phone.
http://developer.android.com/guide/developing/device.html

Tuesday, April 3, 2012

What is LogCat in Android and how can I see logs?

As normal, immediately after starting Android development, I begun editing files directly and in the same speed, I got an error which refer to something called logcat? Error shown was as follows in the console window.


[2012-03-03 12:04:00 - HelloAndroid] Installing HelloAndroid.apk...
[2012-03-03 12:04:01 - HelloAndroid] Installation error: INSTALL_PARSE_FAILED_MANIFEST_MALFORMED
[2012-03-03 12:04:01 - HelloAndroid] Please check logcat output for more details.
[2012-03-03 12:04:01 - HelloAndroid] Launch canceled!
[2012-03-03 12:05:26 - HelloAndroid] ------------------------------

This says something happened while deploying the app to the emulator / device .But for details I need to check something called logcat ? Where is that LogCat located ?

It is another window related to Android development in Eclipse .You can show that as follows.

Widnow -> Show View -> LogCat (with the Android logo)

If you are not able to locate in the show view sub menu select

Window -> Show View -> Others -> Android -> LogCat

This windows is just an UI to see the logs. You can even read and write to the logs. It is little difficult to understand the LogCat messages at first. But will be familiar with no time. My issue was I edited the name of an activity which was mentioned as the Launcher in AndroidManifest.xml. So make sure while renaming the activity modify your manifest as well.

Saturday, March 24, 2012

Opening copied Android project in Eclipse

If you are working with the Eclipse tool for years, you will laugh at this .But this is for the developers like me who came to Eclipse from Visual Studio. In VSTS its very easy we have a .sln file and that cane be directly opened even if we port the project to a new machine or we got a new machine.

The things were not easy for me when I got new Win 7 machine. I backed up every project which were there in my vista machine. Then I setup the Android environment in new machine.Setting up is another big story. There are so many links 1 out there to setup the Android environment. After that when I tried to open my old project I was not able to find any option to open project through menu. ie it lacks File-> Open -> Project or File -> Open Project .Even I was not able to find what is the project file in the folder which I have. There are files with only extension such as .classpath and .project etc...I tried opening that but no chance.

While creating new project there is an option called "Create project from existing source" ie File -> New -> Android Project. I tried that but it said

"An Eclipse project already exists in this directory. Consider using File > Import > Existing Project instead"

Got another clue .I need to import old project. Then I tried that way .It first needed a workspace and when I created a workspace things started working.Thanks God...

Now I really understood why most of the Java training courses include more sessions on "How to use Eclipse?" where .Net teaches you about the language and framework without more importance to VS.

1 See the below links in order to setup environment.
http://developer.android.com/sdk/index.html
http://developer.android.com/resources/tutorials/hello-world.html
http://www.codeproject.com/Articles/102065/Android-A-beginner-s-guide