Showing posts with label Android Environment. Show all posts
Showing posts with label Android Environment. Show all posts

Monday, August 9, 2010

Re-import Android project issue

After my laptop crashes, I have to re-install everything. After importing the existing projects, I got the following error “The method onClick(DialogInterface, int) of type new DialogInterface.OnClickListener(){} must override superclass method”

image

And this is what I found on google:

Eclipse is defaulting to Java 1.5 and you have classes implementing interface methods (which in Java 1.6 can be annotated with @Override, but in Java 1.5 can only be applied to methods overriding a superclass method).

Go to your project/ide preferences and set the java compiler level to 1.6 and also make sure you select JRE 1.6 to execute your program from eclipse.

image

How to debug on device?

For detail information, go to - http://developer.android.com/guide/developing/device.html. The following is a simplified version for my own reference.

1. Declare your application as "debuggable" in your Android Manifest.

In Eclipse, you can do this from the Application tab when viewing the Manifest (on the right side, set Debuggable to true). Otherwise, in the AndroidManifest.xml file, add android:debuggable="true" to the <application> element.

2. Turn on "USB Debugging" on your device.

On the device, go to the home screen, press MENU, select Applications > Development, then enable USB debugging.

3. Setup your system to detect your device.

If you're developing on Windows, you need to install a USB driver for adb. See the Windows USB Driver documentation.

image

Wednesday, April 21, 2010

Android Emulator Issue

Yesterday I resumed the work on improving the Packing List 1.5. However, the Emulator didn’t corporate. It kept crashing. I was so frustrated. I deleted and re-created the image several times. It still didn’t work. The error I received was something like "sad result from adb". What does “sad result” mean? They really should give it better description. Some times I received “the user data image is used by another emulator” while there was only one emulator and one user. I googled and no help. Finally, this morning I tried again, the emulator was so slow to start. So I checked the power mode on my laptop. It turned out I accidently set the power mode to “Power Saver” a couple of days ago. I changed it back. Now everything worked just fine!

Thursday, January 14, 2010

How to deploy Android application?

1. Create icon for your application and add it to the project
 image
image
2. Export unsigned application
Right click on the project. Click on “Android Tools->Export Unsigned Application Package…”
image
2. Generate personal certificate by using keytool in java’s jre\bin directory
image
3. Sign Android application by using jarsigner in jre\bin direcotry
image
4. Installation
a) Install application on emulator
image 
b) Install application on device
I downloaded ASTRO File Manager and copied the apk file to device. Use File Manager to find the file and tap on it. It prompted me a couple of questions. I have to change my device setting to allow unknown source apps to be installed on my device.

How to obtain Google Map Key for Android Application?

This link will give detailed information on how to get Google Map Key for Android Application. I don’t need to repeat it. Here I just want to give simplified steps for future reference:
1. Get MD5 Fingerprint of the Certificate
a) SDK Debug Certificate
image
b) Your Signing Certificate
image
2. Go to this link to sign up for an Android Maps API key
3. Add the key to your application’s AndroidManifest.xml
<com.google.android.maps.MapView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:apiKey="[your key]"
/>

MapActivity cannot be resolved to a type

When I first working on with MapActivity, I got above error. I kept press Ctrl+Shift+O. However, the type just wouldn’t resolve. Finally I found the answer on the Internet. You need to change the build target to “Google API”
Right click on the project. Go to “Properties”. Change the “Build Target” from “Android 1.x to Google APIs 1.x”
image

Tuesday, January 12, 2010

How to kill an application running in Android Emulator?

Since I am not a Java programmer, there is a learning curve using Eclipse. I am getting used it. But sometimes I have to search the Internet to find answers for really simple question like this one. And here is how.
image
1. Click on “DDMS”
2. Select the application you want to kill
3. Click on “Stop”

Android 2.0 Update

To get Android SDK 2.0 update, go to “Windows->Android SDK Manager” to download the new update.
After download the update, I got the following message when try to open my existing application
image
I went to “Help->Software Updates…” and installed the developer tools in below screen shot.
image

Issues with running my first “Hello Android” application

Soon after I have the environment setup, I created my first Android application “Hello Android”. The app is sure simple, but I still run into some issues when running it.
The first one is “HelloAndroidConversion to Delvik format failed with error 1” (see screen shot below)
image
I am not a Java programmer and I have no idea what the issue is. After searching the answer on the Internet, I found the solution. That is go to “Project-Clean…” in Eclipse.
Then I received error “Could not find HelloAndroid.apk!”
 image
It turned out to be the path I added to the system variable. I added “C:\Android\GlassFish-Tools-Bundle-For-Eclipse-1.1\jre\bin” to Path in windows system environment variable. I removed “\bin” and do “Project->Clean…” again. The issue is gone.
The emulator kept shutting down even after I passed these two issues. I had to start the emulator first. Even so, it failed to run it the first time. But it worked the second time and after. Strange!

Thursday, January 7, 2010

Android Development Environment Setup

1. Download Android SDK 1.6
2. Download GlassFish tool bundle for Eclipse 1.1
Don’t ask me why GlassFish. That is the first Eclipse tool I found, so I just installed it.
3. Install Android plug-in in Eclipse
If you got the “No repository found at https://dl-ssl.google.com/android/eclipse/” error when using the URL on Andorid web site which is the checked one in the following screen shot, use the second URL on the screen instead.
image
4. Install AVD(Android Virtual Device)
\[Android sdk folder]\tools\android create avd –-target 2 –-name my_avd
Don’t forget to add “[Eclipse folder]\jre” to the PATH in Environment Variables
5. Set up Android SDK location in Eclipse. Go to Windows->Preferences
image