关于Android开发环境的构建方法总结

 本方法适用于Android SDK 2.1环境下的程序开发

安装JDK
•    在Java.sun.com下载JDK并安装。
•    在“系统属性”的“高级”选项卡中点击“环境变量”,然后添加如下系统环境变量: 

1.  在PATH环境变量后追加 JDK安装路径中的bin路径,本机为:

C:/Program Files/Java/jdk1.6.0_18/bin

2.    新建CLASSPATH环境变量或在CLASSPATH环境变量后追加JDK安装路径中的lib路径和demo路径,本机为:

C:/Program Files/Java/jdk1.6.0_18/demo;C:/Program Files/Java/jdk1.6.0_18/lib

安装Eclipse
•    在eclipse.org下载Eclipse IDE for Java Developers的Windows 32bit版本。
•    下载完成后解压即可使用。

安装Android SDK OR 离线安装
•    在Android Developers下载Android-sdk_r05-windows.zip,下载完成后解压到任意路径。
•    运行SDK Setup.exe,点击Available Packages,如果没有出现可安装的包请点击Settings,选中Misc中的"Force https://..."这项,再点击Available Packages 。
•    选择希望安装的SDK及其文档或者其它包,点击Installation Selected、Accept All、Install Accepted,开始下载安装所选包
•    添加SDK安装目录中的tools文件夹路径至系统PATH环境变量,本机为:
C:/Android/Android-sdk-windows/tools

关于离线安装 

用上面方法更新的时候速度很慢。

更要等很久。所以我们可以直接把那些包下载下来安装。
地址就是
https://dl-ssl.google.com/androi ... 2.0_r01-windows.zip
https://dl-ssl.google.com/androi ... 2.1_r01-windows.zip
https://dl-ssl.google.com/androi ... -1.1_r1-windows.zip
https://dl-ssl.google.com/androi ... 1.5_r03-windows.zip
https://dl-ssl.google.com/androi ... 1.6_r02-windows.zip
https://dl-ssl.google.com/androi ... ver_r03-windows.zip
https://dl-ssl.google.com/androi ... ogle_apis-6_r01.zip
https://dl-ssl.google.com/androi ... ogle_apis-5_r01.zip
https://dl-ssl.google.com/androi ... ogle_apis-4_r02.zip
https://dl-ssl.google.com/androi ... ogle_apis-7_r01.zip

下完之后,
名字以Android的,解压到platforms里面;
以google_apis开头的,解压到addons里面。
usb驱动的,直接解压到根目录。

安装Eclipse插件 ADT
•    Start Eclipse, then select Help > Install New Software.
•    In the Available Software dialog, click Add...
•    In the Add Site dialog that appears, enter a name for the remote site (for example, "Android Plugin") in the "Name" field.
In the "Location" field, enter this URL:
https://dl-ssl.google.com/Android/eclipse/
如果无法通过上面的地址获得插件,可将https替换为http。(https is preferred for security reasons)
•    Back in the Available Software view, you should now see "Developer Tools" added to the list.
•    Select the checkbox next to Developer Tools, which will automatically select the nested tools Android DDMS and Android Development Tools. Click Next.
•    In the resulting Install Details dialog, the Android DDMS and Android Development Tools features are listed.
•    Click Next to read and accept the license agreement and install any dependencies, then click Finish.
•    Restart Eclipse. 

配置ADT 

在Eclipse中:
•    选择Window > Preferences...
•    在左边的面板选择Android,然后在右侧点击Browse...并选中SDK路径,本机为:
C:/Android/Android-sdk-windows
•    点击Apply、OK。配置完成。 

创建AVD 

为使Android应用程序可以在模拟器上运行,必须创建AVD。
•    在Eclipse中。选择Windows > Android SDK and AVD Manager
•    点击左侧面板的Virtual Devices,在右侧点击New
•    填入Name,选择Target的API,SD Card大小任意,Skin随便选,Hardware目前保持默认值
•    点击Create AVD即可完成创建AVD

Create a New Android Project 

After you've created an AVD, the next step is to start a new Android project in Eclipse.
1.    From Eclipse, select File > New > Project.
If the ADT Plugin for Eclipse has been successfully installed, the resulting dialog should have a folder labeled "Android" which should contain "Android Project". (After you create one or more Android projects, an entry for "Android XML File" will also be available.)
2.    Select "Android Project" and click Next.
3.    Fill in the project details with the following values:
o    Project name: HelloAndroid
o    Application name: Hello, Android
o    Package name: com.example.helloAndroid (or your own private namespace)
o    Create Activity: HelloAndroid
o    Min SDK Version: 7
Click Finish.

Here is a description of each field: 

Project Name
This is the Eclipse Project name — the name of the directory that will contain the project files.
Application Name
This is the human-readable title for your application — the name that will appear on the Android device.
Package Name
This is the package namespace (following the same rules as for packages in the Java programming language) that you want all your source code to reside under. This also sets the package name under which the stub Activity will be generated.
Your package name must be unique across all packages installed on the Android system; for this reason, it's very important to use a standard domain-style package for your applications. The example above uses the "com.example" namespace, which is a namespace reserved for example documentation — when you develop your own applications, you should use a namespace that's appropriate to your organization or entity.

Create Activity 

This is the name for the class stub that will be generated by the plugin. This will be a subclass of Android's Activity class. An Activity is simply a class that can run and do work. It can create a UI if it chooses, but it doesn't need to. As the checkbox suggests, this is optional, but an Activity is almost always used as the basis for an application.
Min SDK Version(这个是设置程序希望运行在的系统版本)
==================================
Tips: 这里的Min SDK Version会根据我们选择的Build Target改变,
      表示程序将运行在哪个系统版本之上,对应的数值关系如下:
           Android 1.5:Level API 3
           Android 1.6:Level API 4
           Android 2.01:Level API 6
           Android 2.1:Level API 7
      我们这里选择Android 2.1,故Min SDK Version为7

==================================
This value specifies the minimum API Level required by your application. If the API Level entered here matches the API Level provided by one of the available targets, then that Build Target will be automatically selected (in this case, entering "2" as the API Level will select the Android 1.1 target). With each new version of the Android system image and Android SDK, there have likely been additions or changes made to the APIs. When this occurs, a new API Level is assigned to the system image to regulate which applications are allowed to be run. If an application requires an API Level that is higher than the level supported by the device, then the application will not be installed.
Other fields: The checkbox for "Use default location" allows you to change the location on disk where the project's files will be generated and stored. "Build Target" is the platform target that your application will be compiled against (this should be selected automatically, based on your Min SDK Version).
Notice that the "Build Target" you've selected uses the Android 1.1 platform. This means that your application will be compiled against the Android 1.1 platform library. If you recall, the AVD created above runs on the Android 1.5 platform. These don't have to match; Android applications are forward-compatible, so an application built against the 1.1 platform library will run normally on the 1.5 platform. The reverse is not true.
Your Android project is now ready. It should be visible in the Package Explorer on the left. Open the HelloAndroid.Java file, located inside HelloAndroid > src > com.example.helloAndroid).
It should look like this:

下面是点完Finish按钮之后自动生成的代码:

package com.example.helloAndroid;
import Android.app.Activity;
import Android.os.Bundle;
public class HelloAndroid extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}

it知识库关于Android开发环境的构建方法总结,转载需保留来源!

郑重声明:本文版权归原作者所有,转载文章仅为传播更多信息之目的,如作者信息标记有误,请第一时间联系我们修改或删除,多谢。