If you encounter this problem:

Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lcom/google/ads/AdRequest$ErrorCode;

Chances are you just included the Google Play Services library together with your Google AdMob library.

Since Google AdMob is already part of the Google Play Services library, just remove it. Your ads just be back up in no time.

Android has finally been released by Google and has been making headlines around the dev community. I believe it will be a strong competitor against the Symbian OS and its applications. Currently, Android supports only the Java language, but maybe later on other languages will also be supported. To get your SDK, go here.

Every language always has sample codes provided to help the developer get started and it’s no different with Android. I’m placing a post on how to get started to help developers because I had a hard time actually running a simple hello world application. My desktop PC is running under windows os, once you get the SDK extract it to anywhere you like. To compile Android applications, you can either do it using Eclipse IDE because it has a plugin that does the packaging and compilation of the apps, or use a builder like Ant. I use Ant because you can’t learn the intricacies of the code if you depend too much with IDEs.

To create a new project, use this command.

activityCreator [--out ] your.package.name.WhateverName

The necessary files will be created automatically for you. Go to the File of WhateverName and change the contents of the onCreate() method with this.

TextView tv = new TextView(this);
tv.setText("Hello, Android");

I set the tools location in my environment variables so that I can run it anywhere within the ms-dos console.

You may possibly encounter an error with paths during compilation. Within the Ant script, it actually has an entry there that uses the dx.bat to convert class files to Dalvik executable format (.dex). Just go to the tools folder again and modify the dx.bat file and change the part where dx.jar is indicated so that this file can be seen by the compiler in its classpath.

Once compiled, run emulator by typing emulator and in another ms-dos console, run adb devices. That command starts the adb server if it is not running. Take note that the emulator loads very long on startup. It took me days to figure out that I never did anything wrong but that the emulator just took a long time to load itself up. When the emulator screen pops up, you’ll see the word ANDROID and then after awhile a short red line moving left and right. I thought this was sort of an idle mode for the emulator. Turned out to be like a loading indicator.

You do not need to wait for the emulator to finish loading before installing your application in order to see it. You can use this command to install the Android package.

adb install [pathto]\[package.file]

When your emulator finishes loading itself, you will see your application icon with the title of the app. Click on that and you will see the Hello, Android text. It’s fairly easy when you know the where’s and what of compiling Android applications. I, however had a different situation that it took me a few days to fully understand how the tools work. Android’s documentation focuses mostly using the Eclipse IDE so those who do not like using it, can find this post useful.

Related Posts Plugin for WordPress, Blogger...