搭建android開發環境_第1頁
搭建android開發環境_第2頁
搭建android開發環境_第3頁
搭建android開發環境_第4頁
搭建android開發環境_第5頁
已閱讀5頁,還剩56頁未讀 繼續免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

ThistutorialdescribeshowyoucansetupandevelopmentenvironmentforThistutorialdescribeshowyoucansetupandevelopmentenvironmentforbuildingAndroidappsonanUbuntu11.04desktopusingEclipse,theAndroidSDK,andPhoneGap.IwilldescribehowtobuildAndroidappsfromthecommandlinewithPhoneGapandfromtheGUIwithEclipseandPhoneGapandhowtotesttheminanAndroidemulatorandonarealAndroiddevice.PhoneGapallowsyoutodevelopyourAndroidapplicationsusingwebtechnologiessuchasHTML,CSS,andJavaScript(e.g.withJavaScriptlibrariessuchasjQuery/jQTouch),anditwillturnthesewebappsintonativeAndroidapps(infact,PhoneGapsupportsmultipleplatformssuchasAndroid,Palm,WindowsMobile,Symbian,soyoucanusethesamesourcestocreateappsmultipleIdonotissueanyguaranteethatthiswillworkfor1PreliminaryIwillnotexplainhowtodevelopanAndroidappusingHTML,CSS,andJavaScript.YoucanlotsoftutorialsaboutthisontheInternet,e.g.thisTutorial:AsimpleTwitterclientwithInfact,I'musingaslightlymodifiedversionoftheTwitterclientdescribedinthelinktobuildTwitterappinthistutorial.YoucandownloadmymodifiedversionfromI'mworkingwiththeUbuntuClassicdesktophere(GNOME);thestepsshouldalmostbeifyouuse2InstallingEclipseAndPrerequisitesForTheAndroidFirstopenaterminal(Applications>Accessories>Liux公社(LinuID.c)于2Liux公社(LinuID.c)于26年月2日注冊并開通網站,Liux現在已經成為一種廣受關注和支持的一種操作系統,ID中心,LinuxID就是關于inux的數據中心。LinuxIDC.com提供包括Ubuntu,Fedora,SUSE技術,以及最新IT資訊等Linux專業類網站并被收錄到Google網頁目錄-計算機>軟件>操作系統>Linux目錄Linux公社(LinuxIDC.com)設置了有一定影響力的Linux專題欄目包括Ubuntu專Fedora專RedHat專SUSE專紅旗Linux專Android專Linux公社簡介-廣告服務-網站地圖-幫助信息-聯系我本站(LinuxID)本站帶寬由[6.C友情提供Copyright?2006-2011Linux公 AllrightsEclipseandtheprerequisitesEclipseandtheprerequisitesfortheAndroidSDKandPhoneGapcanbeinstalledassudoapt-getinstallopenjdk-6-jdkeclipserubyrubygemsruby-devlibnokogiri-rubygitlibxml2libxml2-devlibxslt1-Ifyouareona64bitsystem,youalsoneedtoinstallthefollowingtwo3InstallingTheAndroidOpenFirefoxandgoto/sdk/index.html.ThereyouwillfindlinksfortheAndroidSDKforthedifferentplatforms(Windows,MacOSX,Linux).CopythelinklocationofthedownloadforLinux(i386)(don'tworry,thisdownloadworksonbothi386andx86_64...anddownloadanduncompressitas...anddownloadanduncompressitascdThiswillgiveyouthedirectoryandroid-sdk-linux_x86inyourhomedirectory($HOME).$HOME/android-sdk-$HOME/android-sdk-linux_x86/platform-toolsdirectorytoourPATHvariablewhichwedoOpengedit...andaddgedit...andaddthefollowinglineatthebottomofthePATH="$HOME/android-sdk-linux_x86/tools:$HOME/android-sdk-linux_x86/platform-Tomakethechangeeffective(sothatwedon'thavetologoutandbackin),NowstarttheAndroidThisishowtheAndroidSDKSelectSelectAvailablepackagesintheleftpanelandthenselectAndroidRepositoryintherightpaneldownloadSDKTheThepackagesthatbelongtotheAndroidRepositorygroupshouldnowallbechecked.ClicktheInstallSelectedAAnewwindowopens;marktheAcceptradioboxandclickon......tostartthedownloadoftheSDKIfIfADB(AndroidDebugBridge)needstoberestarted,clickonClickClickonCloseafterthedownloadhasfinished-thiswillclosethedownload4Integrating4IntegratingTheAndroidSDKIntoIfyouwanttouseEclipsetocreateyourAndroidappsinsteadofthecommandline,youneedtointegratetheAndroidSDKintoEclipse.Todothis,startEclipse(Applications>Programming>ClickClickonOKifyouseetheWorkspaceLauncherwindow(youcanchecktheUsethisasdefaultanddonotaskagaincheckboxtonotseethismessageNowNowinEclipse,gotoHelp>InstallNewTheTheAvailableSoftwarewindowopens.ClickontheAdd...AsmallAsmallAddSitewindowopens.FillinthefollowingvaluesandclickonBackBackintheAvailableSoftwarewindow,youshouldnowseethesoftwareDeveloperTools.thatsoftwareandclickonNextInInthenextwindow,clickonNext>NowNowacceptthelicenseagreementsandclickonTheThepackagesneededtointegratetheAndroidSDKintoEclipsearenowbeingdownloadedIfIfyouseethefollowingmessageaboutunsignedcontent,it'soktoclickontheOKAtAttheendoftheinstallation,Eclipseneedstoberestarted.Todothis,clickonNowNowthere'sonefinalsteptocompletetheAndroidSDKintegrationinEclipse:GotoWindowInInthePreferenceswindow,selectAndroidintheleftpanel,andthenclickontheBrowse...thatbelongstotheSDKLocationfieldintherightSelectSelectthedirectorywheretheAndroidSDKislocated(it'sandroid-sdk-linux_x86inyourdirectory)andclickonBackBackinthePreferenceswindow,clickonApply(youshouldthenseethesupportedversionsintheTargetName......andthenon5Installing5InstallingToinstallPhoneGap,openFirefoxandgoto/phonegap/phonegap-android.ClickSelectDownloadSelectDownload.tar.gzfromtheoverlaythatcomesIntheFirefoxdownloaddialogue,pleaseIntheFirefoxdownloaddialogue,pleasechooseSaveAfterthedownloadhasfinished,gotothedirectorywherethedownloadhasbeensavedcdTakealookatthedirectory'scontentstolearnhowthePhoneGapdownloadisls-falko@falko-virtual-machine:~/Downloads$ls-total-rw-r--r--1falkofalko114671782011-06-21phonegap-phonegap-android--15-falko@falko-virtual-Asyousee,in-rw-r--r--1falkofalko114671782011-06-21phonegap-phonegap-android--15-falko@falko-virtual-Asyousee,inmycaseitisnamedphonegap-phonegap-android--15-g939754e.tar.gz.letsuncompressthetarxvfzphonegap-phonegap-android--15-Inmycasethiscreatesthedirectoryphonegap-phonegap-android-939754einsidethedirectory.Iwanttomovethatdirectorytomyhomedirectoryandrenameitphonegap-phonegap-mvphonegap-phonegap-android-939754e~/phonegap-phonegap-Wemustaddthebindirectoryinside$HOME/phonegap-phonegap-androidtoourPATHthereforeweedit~/.profilecdgeditTomakethechangeeffective,NowwearefinishedwithsettingupourAndroiddevelopmentenvironment;finallywecanstartthingswith6StartingAnAndroidTheAndroidSDKcomeswithanemulatorsothatyou6StartingAnAndroidTheAndroidSDKcomeswithanemulatorsothatyoucantestyourappsintheemulatorinsteadofonrealAndroiddevice.Tocreateanemulator,wefirstneedtoknowwhichAndroidversions(targets)androidlistfalko@falko-virtual-machine:~$androidlistAvailableAndroidid:1or"android-Name:AndroidType:APIlevel:Revision:Skins:HVGA(default),QVGA-L,HVGA-P,HVGA-L,QVGA-id:2or"android-Name:AndroidType:APIlevel:Revision:Skins:HVGA,QVGA,WVGA854,WVGA800id:3or"android-Name:Android2.1-Type:APIlevel:Revision:Skins:HVGA,QVGA,WQVGA400,WVGA854,WQVGA432,WVGA800id:4or"android-Name:AndroidType:APIlevel:Revision:Skins:HVGA,QVGA,WQVGA400,WVGA854,WQVGA432,WVGA800Name:AndroidType:APIlevel:Revision:Skins:HVGA,QVGA,WQVGA400,WVGA854,WQVGA432,WVGA800id:5or"android-Name:AndroidType:APIlevel:Revision:Skins:HVGA,QVGA,WQVGA400,WVGA854,WQVGA432,WVGA800id:6or"android-Name:AndroidType:APIlevel:Revision:Skins:WXGAid:7or"android-Name:AndroidType:APIlevel:Revision:Skins:WXGAfalko@falko-virtual-IwillnowcreateanemulatorcalledmySimforAndroid2.3.3(id5orandroid-androidcreateavd-nmySim-tandroid-falko@falko-virtual-machine:~$androidcreateavd-nmySim-tandroid-Android2.3.3isabasicAndroidDoyouwishtocreateacustomhardwareDoyouwishtocreateacustomhardwareprofile[no]<--CreatedAVD'mySim'basedonAndroidwiththefollowinghardwarefalko@falko-virtual-Tostarttheemulator,emulator-avdmySim-scaleItcantakeafewminutesuntiltheemulatorisupandrunning,butthenitshouldlookas7CreatingAnAndroidTobuildmyAndroidapp(whichIcallTweetMe)fromitsHTML,CSS,andJavaScriptsources,Icreatefoldercalledtweetmeinmyhomedirectory,andinthattweetmefolderIplaceanotherfoldertweetmewichcontainsthesources(HTML,CSS,||+||||SOURCES(HTML,CSS,Gotocd||+||||SOURCES(HTML,CSS,GotocdYoushouldseetheHTML,CSS,JavaScriptsourcesinthatls-falko@falko-virtual-machine:~/tweetme/tweetme$ls-total-rw-r--r--1falkofalko42332011-01-2400:20drwxr-xr-x2falkofalko40962011-06-2114:23-rw-r--r--1falkofalko786012011-01-2323:15drwxr-xr-x4falkofalko40962011-06-2114:23falko@falko-virtual-Nowwecancreateanappeitherfromthecommandlineorbyusing7.1CreatingAnAndroidAppFromTheCommandInthe~/tweetme/tweetme/directory,7.1CreatingAnAndroidAppFromTheCommandInthe~/tweetme/tweetme/directory,droidgap(Ifyougettheerrormessagedroidgap:commandnotfound,pleaseandtryagain.Thiswillcreatethedirectory~/tweetme/tweetme_androidwhichcontainseverythingweneedtoourfinalappfromit.The~/tweetme/tweetme_android/assets/www/directorycontainsourHTML,JavaScriptsourcesplusthephonegap.<version>.jscdls-falko@falko-virtual-machine:~/tweetme/tweetme_android$ls-total-rw-r--r--1falkofalko22412011-06-2114:25drwxr-xr-x3falkofalko40962011-06-2114:25drwxr-xr-x2falkofalko40962011-06-2114:25-rw-r--r--1falkofalko6962011-06-2114:25-rw-r--r--1falkofalko28912011-06-2114:25-rw-r--r--1falkofalko3632011-06-2114:25drwxr-xr-x2falkofalko40962011-06-2114:25-rw-r--r--1falkofalko4252011-06-2114:25-rw-r--r--1falkofalko11592011-06-2114:25drwxr-xr-x7falkofalko40962011-06-2114:25drwxr-xr-x3falkodrwxr-xr-x7falkofalko40962011-06-2114:25drwxr-xr-x3falkofalko40962011-06-2114:25falko@falko-virtual-ls-lfalko@falko-virtual-machine:~/tweetme/tweetme_android$ls-ltotal-rw-r--r--1falko42332011-06-2114:25drwxr-xr-x2falko40962011-06-2114:25-rw-r--r--1falko786012011-06-2114:25-rw-r--r--1falkofalko1329552011-06-2114:25drwxr-xr-x4falko40962011-06-2114:25falko@falko-virtual-Important:Ifoundaproblemwiththephonegap.0.9.5.jsfile-itcontainsseverallineswithausePolling),andthisisclearlynotwhatyouwantinsideyourapp-seethefollowingAsasolutionforthisproblem,youAsasolutionforthisproblem,youcaneithereditphonegap.0.9.5.jsandcommentoutalllinescontaintheprompt()function(therearesixlines),oryoudownloadPhoneGap0.9.4function),extractthephonegap.0.9.4.jsfilefromit,deletephonegap.0.9.5.jsfromthedirectoryandplacephonegap.0.9.4.jsintheassets/www/directoryIfyouprefertocommentoutalllinesthatcontaintheprompt()functioninphonegap.0.9.5.js,don'twanttoeditthefilemanually,youcanusethefollowingcommandwhichcommentsoutallsixautomatically(thecommandworksfineforphonegap.0.9.5.js;however,itmightnotworkforversions,sopleasekeepthisinsed-i'/prompt/s;^;//;'ls-lfalko@falko-virtual-machine:~/tweetme/tweetme_android$ls-ltotalls-lfalko@falko-virtual-machine:~/tweetme/tweetme_android$ls-ltotal-rw-r--r--1falkofalko1390042011-06-2114:25falko@falko-virtual-Nowwemustedittheindex.htmlfileintheassets/www/folderandaddthefiletothe<head></head>section(beforeallotherJavaScriptfiles/JavaScriptgeditLet'sassumethefilestartsas<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01Transitional//EN"<metahttp-equiv="Content-Type"content="text/html;<!--includeJQuerythroughGoogleAPI=>Alwayshavethelatestversion--><scripttype="text/javascript"<scripttype="text/javascript">google.load("jquery","1.3.2");</script><!--importJQTouch--<scriptsrc="jqtouch/jqtouch.min.js"<!--ImportJQTouchdefaultstyle(iPhoneReplacethestring"themes/apple"with"themes/jq"foranon-iPhonetheme--><linktype="text/css"rel="stylesheet"Addtheline<scripttype="text/javascript"charset="utf-src="phonegap.0.9.5.js"></script>Addtheline<scripttype="text/javascript"charset="utf-src="phonegap.0.9.5.js"></script>beforeallotherJavaScriptsothatitlooksasfollows(ifyoureplacedphonegap.0.9.5.jswithphonegap.0.9.4.js,pleaseusethelinecharset="utf-ant<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01Transitional//EN"<metahttp-equiv="Content-Type"content="text/html;<scripttype="text/javascript"charset="utf-8"<!--includeJQuerythroughGoogleAPI=>Alwayshavethelatestversion--><scripttype="text/javascript"<scripttype="text/javascript">google.load("jquery","1.3.2");</script><!--importJQTouch--<scriptsrc="jqtouch/jqtouch.min.js"<!--ImportJQTouchdefaultstyle(iPhoneReplacethestring"themes/apple"with"themes/jq"foranon-iPhonetheme--><linktype="text/css"rel="stylesheet"media="screen"<linktype="text/css"rel="stylesheet"media="screen"<linktype="text/css"rel="stylesheet"media="screen"ItshouldsayBUILDSUCCESSFULatthe-package-debug-[apkbuilder]Creatingtweetme-debug-unaligned.apkandItshouldsayBUILDSUCCESSFULatthe-package-debug-[apkbuilder]Creatingtweetme-debug-unaligned.apkandsigningitwithadebug[echo]Runningzipalignonfinal[echo]DebugPackage:/home/falko/tweetme/tweetme_android/bin/tweetme-BUILDTotaltime:38falko@falko-virtual-Youcannowfindyourappinthebin/directory(calledtweetme-debug.apk;apkistheextensionAndroidcdls-falko@falko-virtual-machine:~/tweetme/tweetme_android/bin$ls-totaldrwxr-xr-x3falko40962011-06-2114:32-rw-r--r--1falkofalko1556522011-06-2114:32-rw-r--r--1falkofalko1718772011-06-2114:32-rw-r--r--1falkofalko2449002011-06-2114:32tweetme--rw-r--r--1falkofalko2448462011-06-2114:32tweetme-debug-falko@falko-virtual-Toinstallittothefirstrunningemulator,wecanadb-einstall-rtweetme-falko@falko-virtual-machine:~/tweetme/tweetme_android/bin$adb-einstall-rtweetme-411falko@falko-virtual-machine:~/tweetme/tweetme_android/bin$adb-einstall-rtweetme-411KB/s(244900bytesinpkg:/data/local/tmp/tweetme-falko@falko-virtual-(Insteadofrunningantdebugfirstandthenadb-einstall-rtweetme-debug.apkfromthedirectorytoinstalltheapp,wecouldhaveantdebugwhichwouldhavebuiltandafterwardsinstalledtheappinoneNowgotoyouremulator,andyoushouldfindthenewapplistedamongtheotherThisiswhattheapplooks7.2CreatingAnAndroidAppFrom7.2CreatingAnAndroidAppFromInthe~/tweetme/tweetme/directory,droidgap(Ifyougettheerrormessagedroidgap:commandnotfound,pleaseandtryagain.Thiswillcreatethedirectory~/tweetme/tweetme_androidwhichcontainseverythingweneedtoourfinalappfromit.The~/tweetme/tweetme_android/assets/www/directorycontainsourHTML,JavaScriptsourcesplusthephonegap.<version>.jscdls-falko@falko-virtual-machine:~/tweetme/tweetme_android$ls-total-rw-r--r-12011-06-drwxr-xr-32011-06-drwxr-xr-22011-06--rw-r--r-12011-06--rw-r--r-12011-06--rw-r--r-12011-06-drwxr-xr-22011-06--rw-r--r-12011-06--rw-r--r-12011-06-drwxr-xr-7ls-falko@falko-virtual-machine:~/tweetme/tweetme_android$ls-total-rw-r--r-12011-06-drwxr-xr-32011-06-drwxr-xr-22011-06--rw-r--r-12011-06--rw-r--r-12011-06--rw-r--r-12011-06-drwxr-xr-22011-06--rw-r--r-12011-06--rw-r--r-12011-06-drwxr-xr-72011-06-drwxr-xr-32011-06-falko@falko-virtual-ls-lfalko@falko-virtual-machine:~/tweetme/tweetme_android$ls-ltotal-rw-r--r--1falko42332011-06-2114:25drwxr-xr-x2falko40962011-06-2114:25-rw-r--r--1falko786012011-06-2114:25-rw-r--r--1falkofalko1329552011-06-2114:25drwxr-xr-x4falko40962011-06-2114:25falko@falko-virtual-Important:IImportant:Ifoundaproblemwiththephonegap.0.9.5.jsfile-itcontainsseverallineswithausePolling),andthisisclearlynotwhatyouwantinsideyourapp-seethefollowingAsasolutionforthisproblem,youcaneithereditAsasolutionforthisproblem,youcaneithereditphonegap.0.9.5.jsandcommentoutalllinescontaintheprompt()function(therearesixlines),oryoudownloadPhoneGap0.9.4function),extractthephonegap.0.9.4.jsfilefromit,deletephonegap.0.9.5.jsfromthedirectoryandplacephonegap.0.9.4.jsintheassets/www/directoryIfyouprefertocommentoutalllinesthatcontaintheprompt()functioninphonegap.0.9.5.js,don'twanttoeditthefilemanually,youcanusethefollowingcommandwhichcommentsoutallsixautomatically(thecommandworksfineforphonegap.0.9.5.js;however,itmightnotworkforversions,sopleasekeepthisinsed-i'/prompt/s;^;//;'ls-lfalko@falko-virtual-machine:~/tweetme/tweetme_android$ls-ltotal-rw-r--r--1falkofalko1390042011-06-2114:25falko@falko-virtual-NowopenEclipseandgotoFile>New>IntheIntheNewProjectwindow,selectAndroid>AndroidProjectandclickonNextIntheNewIntheNewAndroidProjectwindow,selectCreateprojectfromexistingsource(wehavecreatedthesourcebyrunningdroidgapcreate)andclickontheBrowse...button-don'tfilloutotherfieldsinthatSelectthe~/tweetme/tweetme_androiddirectoryandclickonBackinBackintheNewAndroidProjectwindow,allotherfieldsshouldnowbefilled.ClickonYoushouldnowseeYoushouldnowseethesourcetreeofyourappintheleftpanelinAndroid.Right-clickassets/www/index.htmlfileandselectOpenWith>TextAddthephonegap.<version>.jsfiletothe<head></head>section(beforeallotherLet'sassumethefilestartsas<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01Transitional//EN"<metahttp-equiv="Content-Type"content="text/html;<!--includeJQuerythroughGoogleAPI=>Alwayshavethelatestversion-->Addtheline<scriptAddtheline<scripttype="text/javascript"charset="utf-src="phonegap.0.9.5.js"></script>beforeallotherJavaScriptsothatitlooksasfollows(ifyoureplacedphonegap.0.9.5.jswithphonegap.0.9.4.js,pleaseusethelinetype="text/javascript"charset="utf-8"src="phonegap.0.9.4.js"></script>instead<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01Transitional//EN"<metahttp-equiv="Content-Type"content="text/html;<scripttype="text/javascript"charset="utf-8"<!--includeJQuerythroughGoogleAPI=>Alwayshavethelatestversion--><scripttype="text/javascript"<scripttype="text/javascript">google.load("jquery","1.3.2");</script><!--importJQTouch--<scriptsrc="jqtouch/jqtouch.min.js"<scripttype="text/javascript"<scripttype="text/javascri

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
  • 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論