第一个android程序以及遇到问题解决办法

1 下载最新的 Android SDK 
 http://code.google.com/p/androidforchinadeveloper/downloads/list

2 下载 JDK
http://java.sun.com/javase/downloads/index.jsp

3,下载 Eclipse 3.2,3.3版本(开发 Android的 IDE)
http://www.eclipse.org/downloads/

然后安装android的eclipse插件

 

1. 启动 Eclipse, 选择 Help > Software Updates > Find and Install..
2. 弹出对话框后,选择 Search for new features to install 点击 Nex
3. 点击 New Remote Site.
4. 在编辑框中输入更新插件的网址:
https://dl-ssl.google.com/android/eclipse/. 点击 OK
5. 看到一个更新的列表,点击 sFinish.
6. 在返回的对话框中选择 Android Plugin > Eclipse Integration >
Android Development Tools 并且点击 Next.
7. 选择 Accept terms of the license agreement, 点击 Next.
8. 点击 Finish.
9. 点击 Install All.
10. 重新启动 Eclipse.

这样就安装完毕了

新建一个android项目

选择Next

填写好以后点击Finish

在ApiDemos.java中的代码

package com.example.android.apis;

import android.app.Activity;
import android.os.Bundle;
import android.view.Display;
import android.widget.TextView;

public class ApiDemos extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        TextView textView=new TextView(this);
        Display display=getWindowManager().getDefaultDisplay();
        textView.setText("高度:"+Integer.toString(display.getHeight())+"宽度:"+Integer.toString(display.getWidth()));
        setContentView(textView);
    }
}

  右击项目TheFirstAndroid选择Run AS->Android Application,稍等一会可以看到

进入菜单会看到自己的应用已经在列表里了

整个完成,下面是遇到的问题

1、提示如下错误信息:

[2011-09-04 20:17:37 - TheFirstAndroid] Android Launch!
[2011-09-04 20:17:37 - TheFirstAndroid] adb is running normally.
[2011-09-04 20:17:37 - TheFirstAndroid] Performing com.example.android.apis.ApiDemos activity launch
[2011-09-04 20:17:37 - TheFirstAndroid] Failed to find an AVD compatible with target 'Android 2.2'.
[2011-09-04 20:17:49 - TheFirstAndroid] Still no compatible AVDs with target 'Android 2.2': Aborting launch.
[2011-09-04 20:17:49 - TheFirstAndroid] Performing com.example.android.apis.ApiDemos activity launch
[2011-09-04 20:17:52 - TheFirstAndroid] Launch canceled!

错误解决方案

原因没有新建模拟器;在弹出的框中单击ADD按钮新建一个模拟器然后重启即可

2、提示如下错误信息

[2011-09-04 20:47:24 - TheFirstAndroid] Android Launch!
[2011-09-04 20:47:24 - TheFirstAndroid] adb is running normally.
[2011-09-04 20:47:24 - TheFirstAndroid] Performing com.example.android.apis.ApiDemos activity launch
[2011-09-04 20:47:24 - TheFirstAndroid] Automatic Target Mode: using existing emulator 'emulator-5554' running compatible AVD 'Jerry'
[2011-09-04 20:47:24 - TheFirstAndroid] WARNING: Application does not specify an API level requirement!
[2011-09-04 20:47:24 - TheFirstAndroid] Device API version is 8 (Android 2.2)
[2011-09-04 20:47:24 - TheFirstAndroid] Uploading TheFirstAndroid.apk onto device 'emulator-5554'
[2011-09-04 20:47:24 - TheFirstAndroid] Installing TheFirstAndroid.apk...
[2011-09-04 20:47:32 - TheFirstAndroid] Re-installation failed due to different application signatures.
[2011-09-04 20:47:32 - TheFirstAndroid] You must perform a full uninstall of the application. WARNING: This will remove the application data!
[2011-09-04 20:47:32 - TheFirstAndroid] Please execute 'adb uninstall com.example.android.apis' in a shell.
[2011-09-04 20:47:32 - TheFirstAndroid] Launch canceled!

错误解决方案

这时先运行android模拟机,并在cmd内运行,当然你要定位adb.exe的目录,我是放在D:\android\android-sdk-windows\platform-tools 下

C:\android\android-sdk-windows\platform-tools> adb uninstall com.example.android.apis.

重新运行就可以了

 

重启eclpise有SDK Platform Tools component is missing!

其实这是由于 ADT工具版本 与 Android SDK  Platform-tools Version不匹配造成的, 解决办法就是升级ADT插件的同时, 升级Android SDK  Platform-tools Version。(不是Android SDK Tools, revision 11 噢!)

Window > Android SDK and AVD Manager > Available Packages:

+ Android SDK Platform-tools, revision 3

安装完重启Eclipse即可。

好了,就此Mark!

 

posted @ 2011-09-04 21:48  wangyan9110  阅读(7062)  评论(1编辑  收藏  举报