Android has a great framework to work in. However, it is in its infancy and debugging my code has been a very big problem for me. Whenever something goes wrong in the code, I always get “source not found” error. It doesn’t tell me I have a nullPointer exception , or string is incomplete. No matter what’s wrong with the code, I always get “source not found” error. The reason that happens is Android doesn’t pack the source along with the application it sends to the emulator (maybe they should do that for a debugging run). After searching the net for a while, I came across this solution – wrap your code in a try and catch block and then log the exception to console. Here is an example :
Doing that will display a neat little line in your logcat window (look at the screenshots at the bottom). And, instead of getting the annoying “source not found” error. You will know what the actual error is. In Android, you can log three types of events – information, warning and error. Information is just verbose text being written out to the log. I don’t need to explain warning and errors.
For logging information you can use :
For logging warnings you can use :
I have already shown how to log errors in the code above.
I was messing around with Android’s development kit and I have to say, learning to develop an application for Android was much easier than trying to do it for Windows Mobile. I guess proper documentation helps – a lot. Google has put published tutorials on how to do some common tasks needed for making applications, and has code reference documentation, etcetera which makes it easier to jump into it.
I am a very big fan of MVC and code and design separation in general. I was happy to find out that Android’s API lets you design the user interface in XML and then use that in your program. You can also do the design programmatically but who wants to do that (unless maybe you were adding / removing elements dynamically).
Google also provided an emulator to debug your software. It would have been a nightmare debugging my application without it. Beware of the “source not found” error. Whenever something goes wrong in your application, the debugger tries to reference the source of the place of error. And, the compiler doesn’t include source in the binary from what I understand. So, you get the debugger throws the error “Can’t find source”. There are workarounds for that problem posted on the internet, though.
When I started learning how to program for Windows Mobile (I have a Kaiser so I wanted to an FTP editor for it to edit HTML/PHP/whatever on the go). It took me quite some time to realize that you HAVE to buy Visual Studio if you want to program for it. It took me about a week to get started with Windows Mobile development but it took me a day for Android. And, the studio costs hundreds of dollars so that was out of the question for a hobby. Android, on the other hand, is free so I can use it with no cost at all. Don’t get me wrong. I am not putting Microsoft down. I am a programmer too and I know better than to say all software should be free. People need to make money and without an incentive there won’t be any good software. Visual Studio has great features which make programming very easy. I love their UI designer. I just want to have the choice to be able to program with their SDK without having to shell out 500+ dollars. Maybe if they let me use the SDK for free and asked to be paid for the visual studio, it would be a beter deal.
Anyway, after I got interested in the Android’s SDK, I decided to write some useful applications for it. I’m sure there will be enough users of Tmobile’s G1 phone who will want to use my application *fingers crossed*. Maybe I will make another post of what I plan to make that application do (hint: it will use geo-location service, run in the background and have a UI for settings and such).
If you are too used to programming in Linux and want to move to programming for Windows mobile. It can be a bit hard. It was difficult for someone I know to digest that the SDK requires that you have Visual Studio installed (the full version not the express edition). So, here are a few directions for those who wish to venture into windows mobile programming.
You will need to install .Net Compact Framework 2.0 and 3.5. You can install just 3.5 but it’s better to have both. You will need to install Visual Studio. The latest version of Visual Studio is 2008. WHen you have both of them installed, you can install the WIndows mobile 6 SDk refresh and Windows mobile 5 SDK refresh. And viola ! you can now start programming for windows mobile devices. From what I understand, you can’t program for Windows Mobile outside of Visual Studio. Well there is nothing stopping you from just opening notepad and coding but you have to have Visual Studio installed (along with the other things I mentioned).
As you might already know, there are 2 modes of programming in .NET – managed and unmanaged. Any programs written in C# or Visual Basic are managed; and, anything written in C++ is unmanaged. What does that mean? It means memory is managed for you behind the scenes in C# and Visual Basic. However, you have to do your own memory management (free up memory space, etc). Each of them have their own pros and cons.
Now open Visual Studio and click on new project. Select Smart Device -> Smart Device Project. A new project will be created for you with a default form in design view. On the left you will find a toolbox, which has widgets (controls) for your UI. On the right, you will see a properties section where you can set properties, event handlers, etc for your controls. This should at least help you get started with the setup part of it.
Most of the people who live in New York City take it for granted (including me). So, I decided to explore this beautiful city and see what it has to offer in terms of heritage, activities, etc. I was not dissapointed. I went to the National Museum of American Indian and they had all sorts of things related to Red-Indian culture.
I liked the architecture of the museum. It had beautiful art on the ceiling in the main hall. There were numerous charts, pictures and articles explaining how they (Red Indians) make leather and stitch clothes from them. The decorations that are used (and the materials they made the decorations from), etc. Many dresses were also on the display (one of which was over 500 years old).
Admission to the museum is free. It is open from 10:00 AM – 5:00 PM. However, it is always a good idea to call ahead. Their contact information is :
Here are some pictures from my visit. I apologize for the small size of the pictures. My phone was set to contact pictures instead of regular ones and I was too excited to notice. Maybe I will go there again and get some more pictures.