第一篇:廈門手機開發培訓關于Android開發環境的構建方法總結
廈門手機開發培訓關于Android開發環境的構建方法總結
廈門博看文思本方法適用于AndroidSDK2.1環境下的程序開發
安裝JDK
?在java.sun.com下載JDK并安裝。
?在“系統屬性”的“高級”選項卡中點擊“環境變量”,然后添加如下系統環境變量:
1.在PATH環境變量后追加JDK安裝路徑中的bin路徑,本機為:
C:ProgramFilesJavajdk1.6.0_18bin
2.新建CLASSPATH環境變量或在CLASSPATH環境變量后追加JDK安裝路徑中的lib路徑和demo路徑,本機為:
C:ProgramFilesJavajdk1.6.0_18demo;C:ProgramFilesJavajdk1.6.0_18lib安裝Eclipse
?在eclipse.org下載EclipseIDEforJavaDevelopers的Windows32bit版本。?下載完成后解壓即可使用。
安裝AndroidSDKOR離線安裝
?在AndroidDevelopers下載android-sdk_r05-windows.zip,下載完成后解壓到任意路徑。
?運行SDKSetup.exe,點擊AvailablePackages,如果沒有出現可安裝的包請點擊Settings,選中Misc中的“Forcehttps://...”這項,再點擊AvailablePackages。
?選擇希望安裝的SDK及其文檔或者其它包,點擊InstallationSelected、AcceptAll、InstallAccepted,開始下載安裝所選包
?添加SDK安裝目錄中的tools文件夾路徑至系統PATH環境變量,本機為:C:Androidandroid-sdk-windowstools
關于離線安裝
用廈門博看文思上面方法更新的時候速度很慢。
更要等很久。所以我們可以直接把那些包下載下來安裝。
地址就是
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
?StartEclipse,thenselectHelp>InstallNewSoftware.?IntheAvailableSoftwaredialog,clickAdd...?
IntheAddSitedialogthatappears,enteranamefortheremotesite(forexample,“AndroidPlugin”)inthe“Name”field.Inthe“Location”field,enterthisURL:
https://dl-ssl.google.com/android/eclipse/
如果無法通過上面的地址獲得插件,可將https替換為http。
(httpsispreferredforsecurityreasons)
BackintheAvailableSoftwareview,youshouldnowsee“DeveloperTools”addedtothelist.?
SelectthecheckboxnexttoDeveloperTools,whichwillautomaticallyselectthenestedtoolsAndroidDDMSandAndroidDevelopmentTools.ClickNext.?
IntheresultingInstallDetailsdialog,theAndroidDDMSandAndroidDevelopmentToolsfeaturesarelisted.?
ClickNexttoreadandacceptthelicenseagreementandinstallanydependencies,thenclickFinish.?RestartEclipse.配置ADT
在Eclipse中:
?選擇Window>Preferences...?在左邊的面板選擇Android,然后在右側點擊Browse...并選中SDK路徑,本機為:C:Androidandroid-sdk-windows
?點擊Apply、OK。配置完成。
創建AVD
為使Android應用程序可以在模擬器上運行,必須創建AVD。
?在Eclipse中。選擇Windows>AndroidSDKandAVDManager
?點擊左側面板的VirtualDevices,在右側點擊New
?填入Name,選擇Target的API,SDCard大小任意,Skin隨便選,Hardware目前保持默認值
?點擊CreateAVD即可完成創建AVD
第二篇:關于Android 開發環境的構建方法總結
關于Android開發環境的構建方法總結
作者: 曹亮 發布時間: 2010-03-25 21:31 閱讀: 745 次 原文鏈接 字體: 大 中 小 [收藏]
本方法適用于Android SDK 2.1環境下的程序開發
安裝JDK
? 在java.sun.com下載JDK并安裝。
? 在“系統屬性”的“高級”選項卡中點擊“環境變量”,然后添加如下系統環境變量:
1.在PATH環境變量后追加 JDK安裝路徑中的bin路徑,本機為: C:Program FilesJavajdk1.6.0_18bin 2.新建CLASSPATH環境變量或在CLASSPATH環境變量后追加JDK安裝路徑中的lib路徑和demo路徑,本機為:
C:Program FilesJavajdk1.6.0_18demo;C:Program FilesJavajdk1.6.0_18lib 安裝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:Androidandroid-sdk-windowstools 關于離線安裝
用上面方法更新的時候速度很慢。
更要等很久。所以我們可以直接把那些包下載下來安裝。地址就是 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:Androidandroid-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);} } Notice that the class is based on the Activity class.An Activity is a single application entity that is used to perform actions.An application may have many separate activities, but the user interacts with them one at a time.The onCreate()method will be called by the Android system when your Activity starts — it is where you should perform all initialization and UI setup.An activity is not required to have a user interface, but usually will.Now let's modify some code!構建 UI
Take a look at the revised code below and then make the same changes to your HelloAndroid class.The bold items are lines that have been added.下面讓我們修改一下代碼:
package com.android.helloandroid;import android.app.Activity;import android.os.Bundle;import android.widget.TextView;public class HelloAndroid extends Activity { /** Called when the activity is first created.*/ @Override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState);TextView tv = new TextView(this);tv.setText(“Hello, Android”);setContentView(tv);} } 執行代碼:Hello,Android
Eclipse的插件使得你的程序很容易運行。選擇Run>Open Run Dialog菜單。(Eclipse3.4版本中,菜單為Run->Run Configurations)可以看到這樣的對話框。
下一步,選擇“Android Application”,點擊在左上角(按鈕像一張紙上有個“+”號)或者雙擊“Android Application”。有個新的選項“New_configuration”。
將名字改得更形象一點,如“Hello,Android”,然后按Browse按鈕選擇你的項目,(如果你Eclipse里有多個Android項 目需要打開,確定要選擇正確)插件會會自動掃描你項目里的活動子類,然后在“活動”的下拉菜單里加載。如果你的“Hello,Android”項目只有一 個,它將被設置為默認項目,然后你可以繼續。
點擊“Apply”按鈕,這里有個例子: 這樣就可以了,點擊“Run”按鈕,Android的模擬器啟動。一啟動你的程序就會出現,當一切OK,你可以看到: 這樣就可以了,點擊 “Run”按鈕,Android的模擬器啟動。啟動完畢后你的程序就會出現,如果不出現,有時候是因為有鍵盤鎖的原因,用鼠標將 鍵盤鎖解開就一切OK,你可以看到:Hello Android.使用XML構建UI
你剛 剛完成的“Hello, World”的例子使用的是我們稱為“可編程”的UI層,意思是你通過編寫代碼來組建UI層。當你開發了足夠多的UI程序,你會發現一些很糟糕的現象: 一些小的變化需要你做大量的代碼改動。你常常會忘記將View連接起來,這樣會導致一些錯誤,浪費你很多時間去調試代碼。這就是Android為 什么提供一個可變化的UI開發模塊:基于XML的文件。最簡單解釋這個概念就是演示個例子。這里有個XML的文件,它能達到和你剛才完成代碼同樣的效果:
在這個例子里,有4個XML屬 性,下面是屬性的大概意思:
xmlns:android 這是一個XML命名空間,告訴Android開發工具你準備使用Android命名空間里的一些通用屬性。在所有Android XML設計文件中最外層的標記必須使用這個屬性。
android:layout_width 這個屬性定義了這個視圖需要占用的屏幕寬度。在這個例子中,我們僅有的一個視圖可以占用整個屏幕,那就是“fill_parent”的意思。
android:layout_height 這個和“layout_width”差不多,表示占用屏幕的高度。
android:text 這個設置文本顯示內容,在這個例子里,我們使用“Hello,Android”。
這就是XML的布局,你需要把這個文件放在什么位 置? 放在你的工程/res/layout下就可以。“res”是“resource”的簡稱,這個目錄包含了所有應用程序需要的非代碼部分。比如圖片、字符 串、XML文件。
Eclipse插件為你創建了這些XML文件中的一個。在我們上面的范例,我們根本沒有使用過它。在包的管理器里,展開 目錄/res/layout,編輯main.xml文件,替換上面的文本然后保存修改。
在從代碼目錄里打開 HelloAndroid/gen/com.example.helloandroid/R.java文件,你可以看到他們像這樣: public final class R { public static final class attr { };public static final class drawable { public static final int icon=0x7f020000;};public static final class layout { public static final int main=0x7f030000;};public static final class string { public static final int app_name=0x7f040000;};};R.java是文件中所有資源的索引界定值定義。你在代碼中使用這個類,就像在你的項目里使用一個簡潔的方法表示你 的資源。在Eclipse這樣的IDE工具里,這個方式對于代碼自動完成功能還是非常有效的,因為這能讓你快速得定位你要尋找的東西。
有個重要點 需要注意的是有個內部類“main”,是“layout”的成員類。Eclipse插件提醒你加了一個新的XML文件,然后生成R.java文件,當你加 入其他資源到你的工程里,你可以看到R.java在同步更改。
第三篇:廈門手機開發培訓Android手機模式分析
廈門手機開發培訓Android手機模式分析
第一部分其實游戲就是廈門博看文思讓狀態機不斷的讓Canvas在View上畫你想要的東西。這個狀態機包括內部的執行,還包括外部的輸入。
Android開發的MVC模式
1,通過View和SurfaceView來顯示界面的視圖。(處理界面與用戶的交互事件,如,觸筆點擊,用戶按鍵等。可通過View類的onKeyDown,onKeyUp,onTouchEvent等)。
2,用Activity來控制游戲的整體結構。
3,設計一個邏輯類,用來處理邏輯運算。
Android中任何一個View類都只有重寫onDraw方法來實現界面顯示。
Android中提供了
onKeyUp,onKeyDown,onKeyMultiple,onKeyPreIme,onTouchEvent,onTrackballEvent等方法。可以用來處理游戲中的事件消息。所以繼承View時,需要重載這些方法。Android中提供了invalidate來刷新界面,但invalidate不能直接在線程中調用,違背單線程模型。
因此Android中最常用的方法是利用Handler來時更新UI界面。
第一部分View類
每個View類都有一個繪畫的畫布,在游戲中可以自定義視圖View,任何一個View類都只需要重寫onDraw方法來實現界面顯示,可以是3D,也可以是文本。
游戲的核心就是不斷的繪圖和刷新,圖我們可以通過onDraw方法繪制,刷新
Android中可以用invalidate方法來刷新界面,注意:invalidate不能直接在線程中調用,因其違背了
違背單線程模型。因此Android中最常用的方法是廈門博看文思利用Handler來時更新UI界面。下面這個例子中包含了兩個刷新方法。
第四篇:廈門手機開發培訓分析Android自動化解決方案
廈門手機開發培訓分析Android自動化解決方案
現在,已經有大量的Android自動化測試架構或工具可供我們廈門博看文思使用使用,其中包括:ActivityInstrumentation,MonkeyRunner,Robotium,以及Robolectric。另外LessPainful也提供服務來進行真實設備上的自動化測試。
Android自身提供了對instrumentation測試的基本支持,其中之一就是位于
android.test包內的ActivityInstrumentationTestCase2類,它擴展了JUnit的TestCase類來提供Androidactivities的功能測試。在應用測試中,每一個activity首先會被
Instrumentation初始化,然后再加載到Android模擬器或設備的Dalvik虛擬機中來執行。
AndroidSDK自帶一個測試工具MonkeyRunner,它提供的API和執行環境可以運行Python語言編寫的測試代碼。它提供API來連接設備,安裝/卸載應用,運行應用,截屏,比對圖片來判斷特定命令執行后的屏幕是否包含預期信息,以及運行對應用的測試。MonkeyRunner使用ActivityInstrumentationTestCase2,ProviderTestCase,ServiceTestCasek,SingleLaunchActivityTestCase及其他類來定義測試用例,并使用InstrumentationTestRunner類來運行測試。
Robotium是另一種通過InstrumentationTestRunner來完成Android交互式測試的架構,它橫跨多個activities,支持功能測試,系統測試和接收測試。Robotium支持Activities、Dialogs、Toasts、Menus、ContextMenus甚至Honeycomb,并且它可以同Maven和Ant集成來完成持續集成測試。Robotium被稱之為針對Android應用的又一個Selenium。
Robolectric另辟蹊徑,它并不依賴于Android提供的測試功能,它使用了
shadowobjects并且運行測試于普通的工作站/服務器JVM,不像模擬器或設備需要
dexing(Androiddex編譯器將類文件編譯成Android設備上的DalvikVM使用的格式),打包,部署和運行的過程,大大減少了測試執行的時間。Pivotal實驗室聲稱使用Robolectric可以在28秒內運行1047個測試。
廈門博看文思知道LessPainful將Android測試又推進了一步,它提供了一個多設備平臺自動化測試的服務。用戶上傳應用(*.apk)和用Cucumber(一種業務相關的DSL)編寫的測試文件,選擇測試運行需要的設備配置,最后測試將自動執行并生成測試報告。它支持的設備包括GarminAsus,幾款HTC,LG,SamsungGalaxy,SonyXperia和MotorolaMotodefy。
第五篇:廈門手機開發培訓—軟件工程師談Android開發經驗
廈門手機開發培訓—軟件工程師談Android開發經驗
Android一詞的本義指“機器人”,同時也是Google于2007年11月5日宣布的基于Linux的開源手機操作系統的名稱,該平臺由操作系統、中間件、用戶界面和應用程序組成,是首個真正為移動終端打造的開放并且完整的移動平臺。2008年9月
22日,美國運營商T-MobileUSA在紐約正式發布第一款Google手機,即T-MobileG1,廈門博看文思知道從那個時候起,Android的時代就真正的來臨了。
從Android1.0至今經歷了多次的版本更新,其中重要的變更是1.5、2.0和2.2。而其他的版本更新相對而言并不是那么重要。另外,由于每次更新都會多少改動包括Dalvik在內的底層模塊,同時牽扯到SDK,導致了一些程序需要跟著Android版本進行變動。對于相對較為保守的開發人員而言,快速的版本更新將給他們帶來越來越大的限制。在這種情況下,Android開源的意義就顯得不是那么大了。
無論如何,由于Android與Google服務的緊密捆綁,這款操作系統擁有了得天獨厚的優勢。通過Google強有力的支持,很多事情在Android上都會變得很簡單。另外需要特別提出的是,Android是一款基于互聯網的操作系統,在可以連接上互聯網的情況下,一款Android手機可以發揮出比其他手機更多的能力。而在沒有網絡的情況下,Android手機并不比其他的手機出色,尤其是娛樂性相對于iPhone可以說是遜色不少。作為廈門博看文思開發人員,應當在學習并深入了解Android之后,在自己的軟件中,將Android的優勢發揮出來,同時通過一些手段去彌補Android本身的缺陷或不足。下面來看一下廈門博看文思Android擁有的特點吧:
?與硬件交互非常方便,包括攝像頭、GPS等,都可以簡單的操作。
?擁有自己的運行時和虛擬機,優秀的內存管理能力。
?提供豐富的界面控件供開發者使用,允許可視化開發,并保證Android平臺下的應用程序界面一致。
?提供輕量級的進程間通信機制。
?支持無界面的后臺服務類應用程序。
?支持高效、快速的數據存取方式。
在這些特性的支持下,試圖在Android下開發一個應用不會太過困難。事實上,一個稍有Java經驗的開發人員,都可以快速的上手進行Android的開發。而開發的核心,一直以來也是圍繞著Android手機幾個大的特點來進行的,其中就包括了觸摸屏、攝像頭、GPS模塊、互聯網功能、語音輸入、Google賬戶等。需要說的是,如果一位J2ME工程師想轉行做Android,那么他將付出的代價比J2SE或J2EE工程師要大得多。
畢竟Android所支持的是基本完整的J2SE的子集,反過來再看J2ME就會覺得它的功能太弱了。
除了Java外,還有許多語言支持Android的開發,比較為人所熟知的有Scala,而作為Android本身的底層語言,C/C++的作用也完全不可忽視。而目前的開源社區內,已經有一些牛人在嘗試讓更多的語言可以開發Android應用。比較有代表性的可能是KoushikDutta,他已經解決了在Mono平臺下,讓Dalvik調用Mono代碼的問題。或許在不久的將來,.NET下的所有語言,都有可能借助Mono跑在Android上,這是一件值得讓人期待的事情。
語言已不是問題,那還有什么會成為問題?也許很多人會說經驗。誠然,經驗決定了一位開發人員能否快速地、流暢地完成開發工作,也決定了軟件的魯棒性,Bug的數量、等級和修正問題的返工次數。不過我認為,這些都不重要,哪怕是一個
Android行業的新人,一邊查詢文檔一邊做開發,雖然效率會很低,但是一樣能把項目做完。在Android下,開發技術幾乎是沒有瓶頸的。那么瓶頸在哪里呢?事實上,在用過很多軟件后,就會發現,有很多軟件并不好用。很多用戶不愿意用某個軟件,也并不是因為軟件沒有技術含量或是滿足不了需求,原因很簡單,就是不好用。