Вы находитесь на странице: 1из 30

Part2a

AndroidEnvironment SDK
VictorMatos Victor Matos
ClevelandStateUniversity
Notesarebasedon: Notes are based on:
AndroidDevelopers http://developer.android.com/index.html

AndroidEnvironment: Eclipse&ADT li &


TheAndroidDevelopmentTools(ADT)plugin forEclipseaddspowerfulextensionstotheEclipse integrateddevelopmentenvironment.ItallowsyoutocreateanddebugAndroidapplications i dd l i I ll d d b A d id li i easierandfaster. Advantages 1. ItgivesyouaccesstootherAndroiddevelopmenttoolsfrominsidetheEclipseIDE.For 1 It i t th A d id d l tt l f i id th E li IDE F example,ADTletsyouaccessthemanycapabilitiesoftheDDMStool:takescreenshots, manageportforwarding,setbreakpoints,andviewthreadandprocessinformation directly fromEclipse. 2. ItprovidesaNewProjectWizard,whichhelpsyouquicklycreateandsetupallofthebasic 2 It id N P j t Wi d hi h h l i kl t d t ll f th b i filesyou'llneedforanewAndroidapplication. 3. Itautomatesandsimplifiestheprocessofbuilding yourAndroidapplication. 4. ItprovidesanAndroidcodeeditorthathelpsyouwritevalidXMLforyourAndroidmanifest andresourcefiles. d fil 5. Itwillexport yourprojectintoasignedAPK,whichcanbedistributedtousers.

AndroidSetupVideos Android Setup Videos


Webresources availableat

http://www.hometutorials.com/googleandroid.html
Fivevideos,abitolder(SDK1.0)butusefulnonetheless. 1. 1 2. 3. 4. 5. HowtosetupJava. H t t J HowtoinstallEclipseIDE HowtoInstallAndroidSDKforWindows. InstallingEclipseADTplugin Installing Eclipse ADT plugin Applicationdevelopment:HelloWorldusingEclipse +Android

AndroidSetupTutorial d d l
Webresources availableat:
http://androidcore.com/androidprogrammingtutorials/216howtoinstalltheandroidsdkonwindowsxp.html

HowtoinstalltheAndroidSDKonWindowsXPand CreateanApplicationthatRunsintheAndroidEmulator Create an Application that Runs in the Android Emulator This(PPT)tutorialshowsyouhowtodownloadandinstallAndroidSDK(r1.0)to g y getyoustarteddevelopingAndroidapplications(dothesameforr1.5). p g pp ( )
1.DownloadandInstalltheAndroidSDKandTesttheEmulator 2.InstallJava 3.InstallEclipse 3 Install Eclipse 4.InstalltheADTPlugin inEclipse 5.CreateHelloWorldApplication

AndroidSetupTutorial d d l
Thissectionisbasedonthetutorialavailableat:
http://androidcore.com/androidprogrammingtutorials/216howtoinstalltheandroidsdkonwindowsxp.html

Step1.DownloadandInstalltheAndroidSDKandTestEmulator
1. Createafoldercalledc:\android"inyourc:harddrive. 1 C t f ld ll d \ d id" i h ddi 2. Gotohttp://developer.android.com/sdk/1.5_r2/index.html 3. Clickontheandroid_sdk_windows...link,downloadandsaveittoc:\android.

AndroidSetupTutorial d d l
4. Unzipthedownloadedfile:androidsdkwindows1.5_r1.zip andplaceitscontentsinc:\android. d l i i \ d id

AndroidSetupTutorial d d l
4. 5. Now,setyourEnvironment Variable byrightclickon V i bl b i h li k MyComputer,andselect Properties. UndertheAdvanced tab,hit theEnvironmentVariables button. Inthedialogthatcomesup, doubleclickonPath under SystemVariables addthefull pathtothetools/directoryto thepath,inthiscase,itis: C:\android\tools. ThenclickOK,OK,OK.

6.

7.

AndroidSetupTutorial d d l
Step2. (seeappendixA) CreatinganAndroidVirtualDevice(AVD) 1. Openacommandline(e.g., "Command Prompt"applicationon CommandPrompt application on Windows,or"Terminal"on Mac/Linux)andnavigatetoyourSDK package'stools/directory. 2. First,youneedtoselecta DeploymentTarget.Toviewavailable targets,execute: android list targets Thiswilloutputalistofavailable Androidtargets.Notetheinteger valueoftheid you'llusethisinthe nextstep.
8

AndroidSetupTutorial d d l
Step2.CreatinganAndroidVirtualDeice(AVD)cont. 4. CreateanewAVDusingyourselectedDeploymentTarget.Executethecommand: android create avd -n <your_avd_name> -t <available_targetID> Example:
android create avd n myAVD3 t 3

Lateryou'llseehowtheAVDisusedwhen launchingyourapplicationonanemulator.

AndroidSetupTutorial d d l
Step3.TestAndroidEmulator
UseCommandPromptto enterthefollowingcommand emulator avd myAVD3 Thisinvokesaninstanceoftheemulator UsingtheAVDdefinedintheprevious Step.Itmaytakeawhiletostart!!!. ClickonBrowseicon,youshould reach Cli k B i h ld h Phonesdefaultwebsite(Google.com).

10

AndroidSetupTutorial d d l
Step4.InstallJava 1. 2. 3. 4. 4 5. Gotohttp://developers.sun.com/downloads/ ExpandchoiceJavaSE. Clickon:JavaSE(JDK)6 FromthelistofchoicesselectthemostrecentJavaSEJDK(Update14inourcase). F th li t f h i l t th t tJ SE JDK (U d t 14 i ) ClickontheDownloadbutton

11

AndroidSetupTutorial d d l
Step4.InstallJava 1. 2. 3. 4. 4 OnthenextscreenselectPlatform(Windows)andacceptlicenseagreement. HittheContinue button. Checkbox:JavaSEDevelopmentKit6u14 andclickonthedownload (arrow)symbol Savefiletoc:\ S fil t \

12

AndroidSetupTutorial d d l
Step4.InstallJava 5. Executethedownloadedfile:jdk6u14windowsi586.exe 6. ClickonAccept buttontoagreeonlicensing. 7. NotetheJavafolderlocation.ClickonNext tocompleteinstallation.

13

AndroidSetupTutorial d d l
Step5.InstallEclipseIDE
Eclipse isamultilanguagesoftwaredevelopment platformcomprisinganIDE andaplugin systemto extendit.ItcanbeusedtodevelopapplicationsinJava and,bymeansofthevariousplugins,inother d b f th i l i i th languages (fromWikipedia) 1. Gotohttp://www.eclipse.org/downloads/. p // p g/ / 2. Downloadthecurrentversion(Galileo atthetimeof writing)andsaveittodriveC:\. 3. Unzipthecompressfiletoyourharddrive(c:\eclipse) 4. ForconveniencecreateaShortcuttoeclipse.exe and 4 For convenience create a Shortcut to eclipse exe and placeitonyourDesktop.

14

AndroidSetupTutorial d d l
Step5.InstallEclipseIDE
1. Launcheclipse application. 2. Createafoldertobeyourworkspace

15

AndroidSetupTutorial d d l
Step6.InstallEclipsesADTPlugin p p g
EclipsesADT (AndroidDevelopmentTools)plugin consistsofvariousextensionsthat facilitatesthecreating,running,anddebuggingofAndroidapplications. 1.StartEclipse.Usemainmenu,click 1 St t E li U i li k Help>InstallNewSoftware (Assumingyouareusingadirect Internetconnection) ) 2.TheInstall windowsisdisplayed clickbuttonAdd 3.FilltheName andLocation boxesofthe AddSitewindowwiththeURL https://dlssl.google.com/android/eclipse/ 4.ClickOk.
16

AndroidSetupTutorial d d l
Step6.InstallEclipsesADTPlugin p p g
5.Check DeveloperToolsboxes. Makesurebothoptions: AndroidDDMSand AndroidDeveloperTools A d id D l T l areselected. 6.ClickNext.

17

AndroidSetupTutorial d d l
Step6.InstallEclipsesADTPlugin p p g
TheInstall windowwillbedisplayed offeringdetailsabouttheselected components. 7.ClickFinish. 8.WaitfortheProgressWindowto g indicatecompletionofthe installation. 9. Finallyyouwillbeurgedto 9 Finally you will be urged to restartEclipse.ClickYes.

18

AndroidSetupTutorial d d l
Step6.InstallEclipsesADTPlugin p p g
NowmodifyyourEclipsepreferencestopointtotheAndroidSDKdirectory. 10. SelectWindow>Preferences... toopenthePreferencespanel(Mac:Eclipse> Preferences). 11. SelectAndroid fromtheleftpanel. 12. FortheSDKLocation inthemainpanel,clickBrowse... andlocateyourdownloaded SDKdirectory. SDK directory. 13. ClickApply,thenOK. Done!Youshouldbereadyto startcreatingAndroidapplications. t t ti A d id li ti

19

AndroidSetupTutorial d d l
CreatinganAndroidProject
Reference:http://developer.android.com/guide/developing/eclipseadt.html

Hola Mundo

20

AndroidSetupTutorial d d l
CreatinganAndroidProject g j
Tocreateanewproject: 1. StartEclipse 2. SelectFile >New >Project. 3. SelectAndroid >AndroidProject, 3 S l t A d id > A d id P j t andclickNext. 4. EnterProjectname: AndHolaMundo. 5. SelectTargetAndroid1.5. 6. Applicationname:Hola. 7. Packagename:cis493.demo. 8. CreateActivity:HolaMundo. 9. MinSDKVersion:3. 9 Min SDK Version: 3 10. ClickFinish.

21

AndroidSetupTutorial d d l
CreatinganAndroidProject g j
OnceyoucompletetheNewProjectWizard,ADTcreatesthefollowingfoldersand filesinyournewproject: src/IncludesyourstubActivityJavafile.AllotherJavafilesforyourapplication /I l d t b A ti it J fil All th J fil f li ti gohere. <AndroidVersion>/(e.g.,Android1.5/)Includestheandroid.jarfilethatyour applicationwillbuildagainst. gen/ThiscontainstheJavafilesgeneratedbyADT,suchasyourR.javafileand interfacescreatedfromAIDLfiles. assets/ Thisisempty.Youcanuseittostorerawassetfiles. res/ A folder for your application resources such as drawable files layout files Afolderforyourapplicationresources,suchasdrawable files,layout files, string values,etc. AndroidManifest.xmlTheAndroidManifestforyourproject. default.properties Thisfilecontainsprojectsettings,suchasthebuildtarget.

22

AndroidSetupTutorial d d l
CreatinganAndroid g Project
OnceyoucompletetheNew ProjectWizard,ADTcreatesthe followingfoldersandfilesinyour newproject:

23

AndroidSetupTutorial d d l
CreatinganAndroidProject Creating an Android Project

24

AndroidSetupTutorial d d l
C eat g a CreatinganAndroidProject Debugging d o d oject ebugg g

25

AndroidSetupTutorial d d l
CreatinganAndroidProject Creating an Android Project
package matos.demo; import android.app.Activity; import android.os.Bundle; i i import android.widget.Toast; public class HolaMundo extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); for (int i=0; i<3; i++){ Toast.makeText(getApplicationContext(), i + " Hola Mundo", 1).show(); } Toast.makeText(getApplicationContext(), " Adios", 1).show(); } }

26

AndroidSetupTutorial d d l
CreatinganAndroidProject Creating an Android Project

27

AndroidSetupTutorial d d l

Questions?

28

AndroidSetupTutorial
SummaryofAndroidOnlineInstallationResources
0.JAVA http://www.dailymotion.com/video/x77uqg_googleandroidemulatortutorialtr_tech 1.ECLIPSE http://www.dailymotion.com/related/x77v5t_googleandroideclipseadttutorial_tech/video/x77usr_googleandroideclipsetutorialtra_tech 2.ANDROIDSDK AndroidADTEclipsePluginlink: https://dlssl.google.com/android/eclipse/ http://www.dailymotion.com/related/x77v5t_googleandroideclipseadttutorial_tech/video/x77uou_googleandroidsdkemulatortutoria_tech 3.ECLIPSEPLUGIN http://www.dailymotion.com/related/x77usr_googleandroideclipsetutorialtra_tech/video/x77v5t_googleandroideclipseadt http://www dailymotion com/related/x77usr google android eclipse tutorial tra tech/video/x77v5t google android eclipse adt tutorial_tech?from=rss 4.HELLOWORLDTUTORIAL http://www.dailymotion.com/video/x77v6w_googleandroidappstutorialtraini_tech 5.DROID_DRAW _ http://www.droiddraw.org 6.MAKINGSDCARD http://www.anddev.org/emulating_a_sdcardt263.html http://groups.google.com/group/androiddevelopers/browse_thread/thread/9d068936b43c5f27 http://www.anddev.org/problem_pushing_files_onto_sdcardt2467.html

7.ThreeGOODvideosfromGoogle 1.http://www.youtube.com/watch?v=QBGfUs9mQYY&eurl=http://developerlife.com/theblog/?p=454 2.http://www.youtube.com/watch?v=fL6gSd4ugSI&feature=related 3.http://www.youtube.com/watch?v=MPukbH6DlY&feature=related 8.MoreAPPS http://www.youtube.com/watch?v=1FJHYqE0RDg&feature=channel http://www.youtube.com/watch?v=I6ObTqIiYfE&feature=channel http://www.helloandroid.com/taxonomy/term/29

29

AndroidSetupTutorial
AppendixA. AndroidVirtualDevices AnAVDtellstheemulatorwhatkindofdeviceitissupposetoimpersonate. Currentlythereareonlyafewofthesetargets: Target Description DesignatesanAndroid1.1device,suchasanonupgraded Tmobile G1 IndicatesanAndroid1.5devicethatlacksGoogleMapssupport, whatyoumightgetfromahomebrewportofAndroidontoa y g g p device IdentifiesanAndroid1.5devicethathasGoogleMapssupport [mostlyallnewAndroiddevices]

1 2 3

30

Вам также может понравиться