Tuesday, July 19, 2011

Starting with Android Development

I recently started developing applications for Android. For a beginner, I felt the need of creating a basic Hello World application. I followed the tutorials from this website:
They explained here everything about making and setting up your very first application. I followed everything from step one and was able to come up with this code in the end.

Everything was set. When I pressed F11 to run the application, an error occured:
invalid command-line parameter: Files\Android\android-sdk\tools/emulator-arm.exe
I researched about the error and was able to stumble upon some very useful forum posts at www.stackoverflow.com.

Some of the posts were useless to me. I tried the solution that the first member posted and I only arrived with a warning that I should select an existing directory.
"There is currently a problem with R12 where the SDK location cannot contain any spaces.The default installation location is: C:\Programme Files(x86)\Android\android-sdk. They are currently fixing the problem but you can currently work around it by changing the SDK location path in eclipse to C:\PROGRA~2\Android\android-sdk."
 But I later found out that this process was not going to work on my computer. The reason was because I only had 1 "Program Files" folder. This was only applicable to a directory with 2 folders with that name.

I found my answer in one of the posts by Dennis.

"Doesn't work here. I did everything what the tutorial said, and i got a invalid command-line parameter: Files\Android\android-sdk\tools/emulator-arm.exe.
also "C:\Program Files (x86)\Android\android-sdk\tools\emulator-arm.exe" @foo or C:\Program Files\Android\android-sdk\tools\emulator-arm.exe @foo didn't work also. I am a scripter myself and this is just not good.
ok i fixed it. SOLUTION: change it to C:\PROGRA~1\Android\android-sdk IF you only have 1 folder named program files.
Maybe this helps for others also
With the @foo i did nothing, i just changed the folder to C:\PROGRA~1\Android\android-sdk It is indeed true that this version don't allow spaces in folder paths so in this case with PROGRA~1 he grab the first folder that begins with PROGRA while PROGRA~2 grabs the second folder named program files IF it exists, otherwise if not, the program will say that that folder don't exist."

After fixing the problem, I ran my application and everything went well except for the application's boot time. It took quite a long time to boot and show my first Hello World output in Android. It's normal because When the emulator is booted, the Eclipse plugin installs your application and launches the default Activity. 
When my application finally ran, I noticed that the screen was too wide that I couldn't see the output of my application. In order to fix this, follow these very simple steps:

  1. Go to Window -> Android SDK and AVD Manager -> Virtual Devices
  2. Select the AVD you want to launch and click Start
  3. Check the "Scale display to real size" button
  4. Enter how big you want it to appear in inches and press Launch.

    OR you can also do it in a different way:
  1. Go to Window -> Android SDK and AVD Manager -> Virtual Devices
  2. Select the AVD you want to launch and click Edit
  3. Under the Skin section, you can enter your preferred dimensions of the emulator screen.
  4. Click Edit AVD and close the Android SDK and AVD Manager Dialog box.
Hope this helps you guys on running and setting up your first application! 

No comments:

Post a Comment