1. 程式人生 > >[Andriod官方訓練教程]建立你的第一個App之建立一個Android專案

[Andriod官方訓練教程]建立你的第一個App之建立一個Android專案

-------------------------------------------------------------------------------------

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嚮導。

Create a Project with Eclipse —— 使用Eclipse建立一個專案

  1. Click New  in the toolbar.
  2. In the window that appears, open the Android folder, select Android Application Project, and click Next.

    Figure 1. The New Android App Project wizard in Eclipse.

  3. Fill in the form that appears:
    • Application Name is the app name that appears to users. For this project, use "My First App." 應用的名稱
    • Project Name is the name of your project directory and the name visible in Eclipse. 在Eclipse裡可見的專案名稱
    • Package Name is the package namespace for your app (following the same rules as packages in the Java programming language). Your package name must be unique across all packages installed on the Android system. For this reason, it's generally best if you use a name that begins with the reverse domain name of your organization or publisher entity. For this project, you can use something like "com.example.myfirstapp." However, you cannot publish your app on Google Play using the "com.example" namespace. 你的app的包名稱空間(和Java程式設計中的包規則相同)。你的包名必須在Android系統安裝的所有包中是唯一的。因此,你最好使用以你的組織或出版商的反響域名為開頭來命名。對於這個專案,你可以使用像"com.example.myfirstapp."這樣的名字。但是,你不可以在Google Play上使用"com.example"名稱空間來發布你的app。
    • Minimum Required SDK is the lowest version of Android that your app supports, indicated using the API level. To support as many devices as possible, you should set this to the lowest version available that allows your app to provide its core feature set. If any feature of your app is possible only on newer versions of Android and it's not critical to the app's core feature set, you can enable the feature only when running on the versions that support it (as discussed in Supporting Different Platform Versions). Leave this set to the default value for this project. 你的app支援的最老Android版本,使用API level表明。為了儘可能多的支援不同裝置,你應該將該值設定為允許你的app提供它的核心功能的最老版本號。如果你的app中的任何特性只能執行在較新的Android版本中,並且不是app中的核心功能,你可以僅在支援它的系統版本上才開啟它(正如在Supporting Different Platform Versions討論的一樣)。對於這個專案請保持預設值不變。
    • Target SDK indicates the highest version of Android (also using the API level) with which you have tested with your application. 表明了你的應用測試過的最高的Android系統(同樣使用API level)。

      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等級,以便利用新平臺的特性。

    • Compile With is the platform version against which you will compile your app. By default, this is set to the latest version of Android available in your SDK. (It should be Android 4.1 or greater; if you don't have such a version available, you must install one using the SDK Manager). You can still build your app to support older versions, but setting the build target to the latest version allows you to enable new features and optimize your app for a great user experience on the latest devices. 你編譯你的app時所用的平臺版本。預設下,該值被設為你的SDK上可用的最新安卓版本。(它應該是Android 4.1或更高;如果你沒有這樣一個可用的版本,你必須使用SDK Manager來安裝一個)。你可以仍然使用你的app來支援更老的版本,但是將該值設定為最新版本允許你使用新的特性,並且可以在最新的裝置上擁有更高的使用者體驗來優化你的app。
    • Theme specifies the Android UI style to apply for your app. You can leave this alone. 指定了Android UI風格。你可以先不管這個。

    Click Next.

  4. On the next screen to configure the project, leave the default selections and click Next.
  5. The next screen can help you create a launcher icon for your app. 下一個對話方塊可以幫助你為你的app建立一個啟動圖示。

    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.

  6. Now you can select an activity template from which to begin building your app.

    For this project, select BlankActivity and click Next.

  7. Leave all the details for the activity in their default state and click Finish.

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.

Create a Project with Command Line Tools —— 使用命令列建立一個專案

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來建立你的專案:

  1. Change directories into the Android SDK’s tools/ path. 將目錄改變為Android SDK的 tools/路徑。
  2. Execute:
    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.

    如果你可由看到任何目標列表,你需要使用

  3. Execute:
    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.

現在你的Android專案已經使用一些預設配置建立好啦,你已經準備好開始建立你的app了!請繼續學習下一節課

Tip: Add the platform-tools/ as well as the tools/ directory to your PATH environment variable.

提示:向你的PATH環境變數中新增platform-tools/tools/目錄。

相關推薦

[Andriod官方訓練教程]建立一個App開始另一個Activity

------------------------------------------------------------------------------------------ After completing the previous lesson, you h

[Andriod官方訓練教程]建立一個App建立一個Android專案

------------------------------------------------------------------------------------- An Android project contains all the files that c

[Andriod官方訓練教程]建立一個App建立一個簡單的使用者介面

--------------------------------------------------------------------------------- The graphical user interface for an Android app is b

3) 十分鐘學會android--建立一個APP建立簡單的用戶界面

使用 圖標 run class 屏幕寬度 情況下 不可見 文本輸入框 nes 在本小節裏,我們將學習如何用 XML 創建一個帶有文本輸入框和按鈕的界面。下一節課將學會使 APP 對按鈕做出響應——按鈕被按下時,文本框裏的內容被發送到另外一個 Acti

java小白自己動手開發一個網站建立專案及域名訪問(5回)

新手小白,大神們看到什麼問題,請多多指出 目錄 一、建立專案  1.建立web專案,新增一個index.html頁面, 2.建立一個本地服務tomcat,並配置(檢驗tomcat是否成功,http://localhost:8080/) 3.後將專案新增進去,本地測試

java小白自己動手開發一個網站搭建一個網站需要啥(2回)

新手小白,大神們看到什麼問題,請多多指出 目錄 新手小白,大神們看到什麼問題,請多多指出 搭建網站的流程 註冊域名 購買空間 製作網站 搭建網站的流程 搭建網站有哪些流程 1\註冊域名  2\購買空間  3\製作網站  &

android studio 創建一個apphello world

inf nbsp demo you per span instance 分享圖片 null android studio 創建第一個app之hello world 想要用studio創建一個簡單的app,結果遇到各種問題,application就是允許不起來,後來在

Android 中如何從一個App啟動另外一個App(如啟動支付界面、啟動地圖界面、應用商場下載App等場景)

!= oid 等等 信息 fault next -a return 5.1   假定兩個App,分別是A和B,當A運行某個功能需要啟動B,一種是啟動B應用,一種直接進入B的某個Activity。搜了很多資料,沒有一個完整的。下面就A--Android5.1.1、B--And

如何用一個app操作另外一個app.比如微信群控那樣的

target html ref repl reply 如何實現 tle net htm 如何實現一個app.控制另外的app,比如市面上群控微信的,是用測試工具的原理?還是什麽模擬點擊的原理?

iOS 從一個app開啟另一個app

第一步:對B操作(對B的info.plist中自定義url types) 注意, 這裡的URL Schemes必填, URL identifier選填。 另外,URL Schemes建議都小寫,由於之後接收到資料的時候,不區分大寫和小寫, 都是轉為小寫。 規定的格式是   URL Schemes://

[安卓開發基礎] 通過包名啟動一個APP 的 某一個Activity 或者另外一個app

 通過包名稱啟動同一個應用不同包名稱下的 Activity   //第一個引數為工程包名 可以直接使用 this,第二個為啟動的Actvity 完整路徑。填寫錯誤會提示  Activity  找不到。 Intent inten

Android一個APP檢測另一個APP的Service被殺死時自動重啟服務

例如:appA要檢測啟動appB中的service 1.修改B中Service啟動時的FLAG @Override public int onStartCommand(Intent

Android 通過一個app 啟動另一個app

PackageManager packageManager = getPackageManager(); String packname="";//此處為包名 if (checkPackInfo(packname)) {//檢查是否有要開啟的app Intent intent = packag

一個APP啟動另一個APP的activity的方式

從一個APP啟動另一個APP的Activity的方法 1、通過自定義action啟動 這種方式只需要在程式碼中設定一個action即可, 系統會自動過濾去找到這個action所對應的Activity 當前APP的程式碼 Intent intent =

android 實現一個app啟動另一個app的service服務

首先我們建立兩個android 工程 這裡我們稱被啟動的app為甲,啟動被啟動的app為已,首先我們在甲 app類中new一個Myservice類 在類的onCreate函式中我們寫一個匿名執行緒 public class MyService exte

一個App與另一個App之間的互動,添加了自己的一些理解

URL Scheme 是什麼? iOS有個特性就是應用將其自身”繫結”到一個自定義 URL scheme 上,該 scheme用於從瀏覽器或其他應用中啟動本應用。常見的分享到第三方之間的跳轉都是基於Scheme的。 通過對比網頁連結來理解iOS 上的 URL Schemes

WPF入門教程系列(一) 建立一個WPF專案

WPF基礎知識 快速學習絕不是從零學起的,良好的基礎是快速入手的關鍵,下面先為大家摞列以下自己總結的學習WPF的幾點基礎知識: 1) C#基礎語法知識(或者其他.NET支援的語言):這個是當然的了,雖然WPF是XAML配置的,但是總還是要寫程式碼的,相信各

Unity 5.3 官方VR教程(二) 建立一個VR專案

4.VR中的影象效果(Image Effect) 在VR專案中使用眾多影象效果是很奢侈的事情。考慮到你需要兩次渲染同一個場景(每隻眼睛一次),因此很多當前經常使用的影象效果對VR應用來說會很浪費,會嚴重影響遊戲的執行幀速。 因為VR將使用者的眼睛置入一個虛擬的空間,因此部分影象效果對VR來說沒有任何意義。

Asp.net core實戰4: 建立一個Asp.net core專案

我們劃分為四個步驟建立你的第一個專案: 1.根據官方提供的模板生成一個專案 2.使用NuGet修復所缺少的第三方庫 3.Build你的專案 4.Run你的專案   第一步:建立專案(請自行下載安裝Asp.net core SDK 2.0及Visual Studio2

OutSystems中建立一個web應用

利用OutSystems開發 Web 應用程式非常簡單。如果您有包含資料的 Excel 檔案,則可以將其匯入資料庫並快速建立企業級應用程式來管理資料。如果您沒有準備好 Excel 檔案,請不要擔心,我們會為您提供樣本檔案。 要使用從Excel檔案匯入的資料建立應用程式,您需要: