Building Your First App---Creating an Android Project
原文地址:http://developer.android.com/training/basics/firstapp/creating-project.html
-------------------------------------------------
An Android project contains all the files that comprise the source code for your Android app. The Android SDK tools make it easy to start a new Android project with a set of default project directories and files.
一个Android项目包含了所有你的Android应用代码所需的所有文件。Android SDK工具使用一系列默认的项目目录和文件使得开始一个Android项目更加容易。
This lesson shows how to create a new project either using Eclipse (with the ADT plugin) or using the SDK tools from a command line.
这节课向你展示如何使用Eclipse(安装了ADT插件)或在命令行中使用SDK工具创建一个新的项目。
Note: You should already have the Android SDK installed, and if you're using Eclipse, you should also have the ADT plugininstalled (version 21.0.0 or higher). If you don't have these, follow the guide to Installing the Android SDK before you start this lesson.
注意:你应该已经安装了Android SDK,并且如果你使用Eclipse,你同样应该安装了ADT插件(版本21.0.0及更高)。如果没有这些,在开始这节课之前你应该首先阅读Installing the Android SDK向导。
Figure 1. The New Android App Project wizard in Eclipse.
As new versions of Android become available, you should test your app on the new version and update this value to match the latest API level in order to take advantage of new platform features.
当新的Android系统可用时,你应该在新的版本上测试你的app,然后更新该值来匹配最新的API等级,以便利用新平台的特性。
Click Next.
You can customize an icon in several ways and the tool generates an icon for all screen densities. Before you publish your app, you should be sure your icon meets the specifications defined in the Iconography design guide.
你可以用很多方法自定义一个图标,然后工具会为所有大小的屏幕生成一个图标。在你发布你的app之前,你应该确保你的图标符合Iconography设计指南中定义的规格。
Click Next.
For this project, select BlankActivity and click Next.
Your Android project is now set up with some default files and you’re ready to begin building the app. Continue to the next lesson.
If you're not using the Eclipse IDE with the ADT plugin, you can instead create your project using the SDK tools from a command line:
如果你没有使用安装了ADT插件的Eclipse IDE,你可以在命令行中使用SDK来创建你的项目:
tools/
path. 将目录改变为Android SDK的 tools/路径。android list targets
This prints a list of the available Android platforms that you’ve downloaded for your SDK. Find the platform against which you want to compile your app. Make a note of the target id. We recommend that you select the highest version possible. You can still build your app to support older versions, but setting the build target to the latest version allows you to optimize your app for the latest devices.
这会打印出你已经下载的可用Android平台的列表。找打你想要编译你的app使用的平台。记住目标id。我们建议你尽可能选择最高版本。你可以仍然建立你的app来支持更高的版本,但是设置为最新版本允许你为最新的设备优化你的app。
If you don't see any targets listed, you need to install some using the Android SDK Manager tool. See Adding Platforms and Packages.
如果你可由看到任何目标列表,你需要使用Android SDK Manager工具安装一些。参见Adding Platforms and Packages。
android create project --target <target-id> --name MyFirstApp \--path <path-to-workspace>/MyFirstApp --activity MainActivity \--package com.example.myfirstapp
Replace <target-id>
with an id from the list of targets (from the previous step) and replace <path-to-workspace>
with the location in which you want to save your Android projects.
将<target-id>替换为目标列表中的一个id(在上一步中得到),然后将<path-to-workspace>替换为你想要保存你的Android项目的位置。
Your Android project is now set up with several default configurations and you’re ready to begin building the app. Continue to the next lesson.
Tip: Add the platform-tools/
as well as the tools/
directory to your PATH
environment variable.
提示:向你的PATH环境变量中添加platform-tools/和tools/目录。