版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
ThistutorialdescribeshowyoucansetupandevelopmentenvironmentforbuildingAndroidappsonanUbuntu11.04desktopusingEclipse,theAndroidSDK,andPhoneGap.IwilldescribehowtobuildAndroidappsfromthecommandlinewithPhoneGapandfromtheGUIwithEclipseandPhoneGapandhowtotesttheminanAndroidemulatorandonarealAndroiddevice.PhoneGapallowsyoutodevelopyourAndroidapplicationsusingwebtechnologiessuchasHTML,CSS,andJavaScript(e.g.withJavaScriptlibrariessuchasjQuery/jQTouch),anditwillturnthesewebappsintonativeAndroidapps(infact,PhoneGapsupportsmultipleplatformssuchasAndroid,iPhone,Palm,WindowsMobile,Symbian,soyoucanusethesamesourcestocreateappsformultipleplatforms).Idonotissueanyguaranteethatthiswillworkforyou!1PreliminaryNoteIwillnotexplainhowtodevelopanAndroidappusingHTML,CSS,andJavaScript.YoucanfindlotsoftutorialsaboutthisontheInternet,e.g.thisone:Tutorial:AsimpleTwitterclientwithInfact,I'musingaslightlymodifiedversionoftheTwitterclientdescribedinthelinktobuildaTwitterappinthistutorial.Youcandownloadmymodifiedversionfromhere: I'mworkingwiththeUbuntuClassicdesktophere(GNOME);thestepsshouldalmostbeidenticalifyouuseUnity.InstallingEclipseAndPrerequisitesForTheAndroidSDK/PhoneGapFirstopenaterminal(Applications>Accessories>Terminal):Lix公社(LinuID.c)于26年月2日注冊(cè)并開(kāi)通網(wǎng)站,Liux現(xiàn)在已經(jīng)成為一種廣受關(guān)注和支持的一種操作系統(tǒng),ID中心,LinuxID就是關(guān)于inux的數(shù)據(jù)中心。并被收錄到Google網(wǎng)頁(yè)目錄-計(jì)算機(jī)>軟件>操作系統(tǒng)>Linux目錄下。Ubuntu專(zhuān)題Fedora專(zhuān)題RedHat專(zhuān)題紅旗LinuxAndroidLinux公社簡(jiǎn)介-廣告服務(wù)-網(wǎng)站地圖-幫助信息-本站(LinuxID)本站帶寬由[668.CC友情提供Copyright?2006-2011Linux公社AllrightsEclipseandtheprerequisitesfortheAndroidSDKandPhoneGapcanbeinstalledassudoapt-getinstallopenjdk-6-jdkeclipserubyrubygemsruby-devlibnokogiri-rubygitantlibxml2libxml2-devlibxslt1-devIfyouareona64bitsystem,youalsoneedtoinstallthefollowingtwopackages:sudoapt-getinstalllib32stdc++6ia32-libsInstallingTheAndroidOpenFirefoxandgoto/sdk/index.html.ThereyouwillfindlinksfortheAndroidSDKforthedifferentplatforms(Windows,MacOSX,Linux).CopythelinklocationofthedownloadforLinux(i386)(don'tworry,thisdownloadworksonbothi386andx86_64...anddownloadanduncompressitascdwget/android/android-sdk_r11-linux_x86.tgztarxvfzandroid-sdk_r11-linux_x86.tgzThiswillgiveyouthedirectoryandroid-sdk-linux_x86inyourhomedirectory($HOME).We $HOME/android-sdk-linux_x86/platform-toolsdirectorytoourPATHvariablewhichwedoasOpengedit...andaddthefollowinglineatthebottomoftheTomakethechangeeffective(sothatwedon'thavetologoutandbackin),run:NowstarttheAndroidSDK:ThisishowtheAndroidSDKSelectAvailablepackagesintheleftpanelandthenselectAndroidRepositoryintherightpaneltodownloadSDKpackages:ThepackagesthatbelongtotheAndroidRepositorygroupshouldnowallbechecked.ClickontheInstallSelectedbutton:Anewwindowopens;marktheAcceptradioboxandclickon...tostartthedownloadoftheSDKIfADB(AndroidDebugBridge)needstoberestarted,clickonClickonCloseafterthedownloadhasfinished-thiswillclosethedownloadIntegratingTheAndroidSDKIntoIfyouwanttouseEclipsetocreateyourAndroidappsinsteadofthecommandline,youneedtointegratetheAndroidSDKintoEclipse.Todothis,startEclipse(Applications>Programming>ClickonOKifyouseetheWorkspaceLauncherwindow(youcanchecktheUsethisasthedefaultanddonotaskagaincheckboxtonotseethismessageanymore):NowinEclipse,gotoHelp>InstallNewTheAvailableSoftwarewindowopens.ClickontheAdd...AsmallAddSitewindowopens.FillinthefollowingvaluesandclickonOK:Name:ADTPluginBackintheAvailableSoftwarewindow,youshouldnowseethesoftwareDeveloperTools.SelectthatsoftwareandclickonNext>:Inthenextwindow,clickonNext>NowacceptthelicenseagreementsandclickonThepackagesneededtointegratetheAndroidSDKintoEclipsearenowbeingdownloadedandIfyouseethefollowingmessageaboutunsignedcontent,it'soktoclickontheOKAttheendoftheinstallation,Eclipseneedstoberestarted.Todothis,clickonNowthere'sonefinalsteptocompletetheAndroidSDKintegrationinEclipse:GotoWindow>InthePreferenceswindow,selectAndroidintheleftpanel,andthenclickontheBrowse...buttonthatbelongstotheSDKLocationfieldintherightpanel:SelectthedirectorywheretheAndroidSDKislocated(it'sandroid-sdk-linux_x86inyourhomedirectory)andclickonOK:BackinthePreferenceswindow,clickonApply(youshouldthenseethesupportedAndroidversionsintheTargetNamecolumn)......andthenonInstallingToinstallPhoneGap,openFirefoxandgoto/phonegap/phonegap-android.ClickontheDownloadsbutton:SelectDownload.tar.gzfromtheoverlaythatcomesIntheFirefoxdownloaddialogue,pleasechooseSaveAfterthedownloadhasfinished,gotothedirectorywherethedownloadhasbeensavedcdcdTakealookatthedirectory'scontentstolearnhowthePhoneGapdownloadislsls-falko@falko-virtual-machine:~/Downloads$ls-ltotal11200-rw-r--r--1falkofalko114671782011-06-2114:01Asyousee,inmycaseitisnamedphonegap-phonegap-android--15-g939754e.tar.gz.Nowletsuncompressthefile:directory.IwanttomovethatdirectorytomyhomedirectoryandrenameitWemustaddthebindirectoryinside$HOME/phonegap-phonegap-androidtoourPATHvariable,thereforeweedit~/.profileagain:cdcdgeditTomakethechangeeffective,NowwearefinishedwithsettingupourAndroiddevelopmentenvironment;finallywecanstartdoingthingswithit!StartingAnAndroidTheAndroidSDKcomeswithanemulatorsothatyoucantestyourappsintheemulatorinsteadofonarealAndroiddevice.Tocreateanemulator,wefirstneedtoknowwhichAndroidversions(targets)areandroidandroidlistfalko@falko-virtual-machine:~$androidlisttargetsAvailableAndroidtargets:id:1or"android-3"Name:Android1.5Type:PlatformAPIlevel:3Revision:Skins:HVGA(default),QVGA-L,HVGA-P,HVGA-L,QVGA-id:2or"android-4"Name:Android1.6Type:PlatformAPIlevel:4Revision:Skins:HVGA,QVGA,WVGA854,WVGA800id:3or"android-Name:Android2.1-update1Type:PlatformAPIlevel:Revision:Skins:HVGA,QVGA,WQVGA400,WVGA854,WQVGA432,WVGA800id:4or"android-Name:Android2.2Type:PlatformAPIlevel:8Revision:Skins:HVGA,QVGA,WQVGA400,WVGA854,WQVGA432,WVGA800id:5or"android-10"Name:Android2.3.3Type:PlatformAPIlevel:Revision:Skins:HVGA,QVGA,WQVGA400,WVGA854,WQVGA432,WVGA800id:6or"android-11"Name:Android3.0Type:PlatformAPIlevel:11Revision:Skins:WXGA(default)id:7or"android-12"Name:Android3.1Type:PlatformAPIlevel:12Revision:Skins:WXGA(default)IwillnowcreateanemulatorcalledmySimforAndroid2.3.3(id5orandroid-androidandroidcreateavd-nmySim-tandroid-falko@falko-virtual-machine:~$androidcreateavd-nmySim-tandroid-10Android2.3.3isabasicAndroidplatform.Doyouwishtocreateacustomhardwareprofile[no]<--CreatedAVD'mySim'basedonAndroid2.3.3,withthefollowinghardwareconfig:Tostarttheemulator,emulatoremulator-avdmySim-scaleItcantakeafewminutesuntiltheemulatorisupandrunning,butthenitshouldlookasTobuildmyAndroidapp(whichIcallTweetMe)fromitsHTML,CSS,andJavaScriptsources,Icreateafoldercalledtweetmeinmyhomedirectory,andinthattweetmefolderIplaceanotherfoldercalledtweetmewichcontainsthesources(HTML,CSS,JavaScript):||+||||SOURCES(HTML,CSS,GotocdcdYoushouldseetheHTML,CSS,JavaScriptsourcesinthatlsls-falko@falko-virtual-machine:~/tweetme/tweetme$ls-ltotal96-rw-r--r--1falkofalko42332011-01-2400:20drwxr-xr-x2falkofalko40962011-06-2114:23-rw-r--r--1falkofalko786012011-01-2323:15drwxr-xr-x4falkofalko40962011-06-2114:23themesNowwecancreateanappeitherfromthecommandlineorbyusingdroidgapdroidgap(Ifyougettheerrormessagedroidgap:commandnotfound,pleaseandtryagain.Thiswillcreatethedirectory~/tweetme/tweetme_androidwhichcontainseverythingweneedtobuildJavaScriptsourcesplusthephonegap.<version>.jsfile.ls-lfalko@falko-virtual-machine:~/tweetme/tweetme_android$ls-ltotal44-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:25ls-lls-lfalko@falko-virtual-machine:~/tweetme/tweetme_android$ls-lassets/www/total228-rw-r--r--1falko 42332011-06-2114:25drwxr-xr-x2falko 40962011-06-2114:25-rw-r--r--1falkofalko786012011-06-2114:25-rw-r--r--1falkofalko1329552011-06-2114:25drwxr-xr-x4falkofalko 40962011-06-2114:25themesImportant:Ifoundaproblemwiththephonegap.0.9.5.jsfile-itcontainsseverallineswithaprompt()functionthataskstheusersomequestions(itasksforgetPort,getToken,getServer,restartServer,usePolling),andthisisclearlynotwhatyouwantinsideyourapp-seethefollowingscreenshots:Asasolutionforthisproblem,youcaneithereditphonegap.0.9.5.jsandcommentoutalllinesthatcontaintheprompt()function(therearesixlines),oryoudownloadPhoneGap0.9.4from/files/phonegap-0.9.4.zip(PhoneGap0.9.4doesn'tusetheprompt()function),extractthephonegap.0.9.4.jsfilefromit,deletephonegap.0.9.5.jsfromtheassets/www/directoryandplacephonegap.0.9.4.jsintheassets/www/directoryinstead.Ifyouprefertocommentoutalllinesthatcontaintheprompt()functioninphonegap.0.9.5.js,butdon'twanttoeditthefilemanually,youcanusethefollowingcommandwhichcommentsoutallsixlinesautomatically(thecommandworksfineforphonegap.0.9.5.js;however,itmightnotworkforfutureversions,sopleasekeepthisinmind!):sedsed-i'/prompt/s;^;//;'lsls-lfalko@falko-virtual-machine:~/tweetme/tweetme_android$ls-llibs/total136-rw-r--r--1falkofalko1390042011-06-2114:25phonegap.0.9.5.jarNowwemustedittheindex.htmlfileintheassets/www/folderandaddthegeditgeditLet'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"media="screen"<link<linktype="text/css"rel="stylesheet"media="screen"Addtheline<scripttype="text/javascript"charset="utf-8"src="phonegap.0.9.5.js"></script>beforeallotherJavaScriptsothatitlooksasfollows(ifyouhavereplacedphonegap.0.9.5.jswithphonegap.0.9.4.js,pleaseusetheline<scripttype="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"<!--ImportJQTouchdefaultstyle(iPhoneReplacethestring"themes/apple"with"themes/jq"foranon-iPhonetheme--><linktype="text/css"rel="stylesheet"media="screen"<linktype="text/css"rel="stylesheet"media="screen"antantItshouldsayBUILDSUCCESSFULatthe[apkbuilder]Creatingtweetme-debug-unaligned.apkandsigningitwithadebug[echo]RunningzipalignonfinalBUILDTotaltime:38Youcannowfindyourappinthebin/directory(calledtweetme-debug.apk;apkistheextensionforAndroidapps):ls-lfalko@falko-virtual-machine:~/tweetme/tweetme_android/bin$ls-ltotal808drwxr-xr-x3falko 40962011-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-unaligned.apkToinstallittothefirstrunningemulator,wecanadbadb-einstall-rtweetme-falko@falko-virtual-machine:~/tweetme/tweetme_android/bin$adb-einstall-rtweetme-d411KB/s(244900bytesin(Insteadofrunningantdebugfirstandthenadb-einstall-rtweetme-debug.apkfromthedirectorytoinstalltheapp,wecouldhaveantantdebugwhichwouldhavebuiltandafterwardsinstalledtheappinoneNowgotoyouremulator,andyoushouldfindthenewapplistedamongtheotherThisiswhattheapplooksdroidgapdroidgap(Ifyougettheerrormessagedroidgap:commandnotfound,pleaseandtryagain.Thiswillcreatethedirectory~/tweetme/tweetme_androidwhichcontainseverythingweneedtobuildJavaScriptsourcesplusthephonegap.<version>.jsfile.cdcdlsls-totasls-lfalko@falko-virtual-machine:~/tweetme/tweetme_android$ls-lassets/www/total228-rw-r--r--1falko 42332011-06-2114:25drwxr-xr-x2falko 40962011-06-2114:25-rw-r--r--1falkofalko786012011-06-2114:25-rw-r--r--1falkofalko1329552011-06-2114:25drwxr-xr-x4falkofalko 40962011-06-2114:25themesImportant:Ifoundaproblemwiththephonegap.0.9.5.jsfile-itcontainsseverallineswithaprompt()functionthataskstheusersomequestions(itasksforgetPort,getToken,getServer,restartServer,usePolling),andthisisclearlynotwhatyouwantinsideyourapp-seethefollowingscreenshots:Asasolutionforthisproblem,youcaneithereditphonegap.0.9.5.jsandcommentoutalllinesthatcontaintheprompt()function(therearesixlines),oryoudownloadPhoneGap0.9.4from/files/phonegap-0.9.4.zip(PhoneGap0.9.4doesn'tusetheprompt()function),extractthephonegap.0.9.4.jsfilefromit,deletephonegap.0.9.5.jsfromtheassets/www/directoryandplacephonegap.0.9.4.jsintheassets/www/directoryinstead.Ifyouprefertocommentoutalllinesthatcontaintheprompt()functioninphonegap.0.9.5.js,butdon'twanttoeditthefilemanually,youcanusethefollowingcommandwhichcommentsoutallsixlinesautomatically(thecommandworksfineforphonegap.0.9.5.js;however,itmightnotworkforfutureversions,sopleasekeepthisinmind!):sedsed-i'/prompt/s;^;//;'lsls-lfalko@falko-virtual-machine:~/tweetme/tweetme_android$ls-llibs/total136-rw-r--r--1falkofalko1390042011-06-2114:25phonegap.0.9.5.jarNowopenEclipseandgotoFile>New>IntheNewProjectwindow,selectAndroid>AndroidProjectandclickonNextcreatedthesourcebyrunningdroidgapcreate)andclickontheBrowse...button-don'tfilloutanyotherfieldsinthatwindow:BackintheNewAndroidProjectwindow,allotherfieldsshouldnowbefilled.ClickonYoushouldnowseethesourcetreeofyourappintheleftpanelinAndroid.Right-clickassets/www/index.htmlfileandselectOpenWith>TextAddthephonegap.<version>.jsfiletothe<head></head>section(beforeallotherJavaScriptfiles/JavaScriptcode).Let'sassumethefilestartsas<!DOCTYPE<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01Transitional//EN"<metahttp-equiv="Content-Type"content="text/html;<!--includeJQuerythroughGoogleAPI=>Alwayshavethelatestversion--><scripttype="text/javascript"<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"Addtheline<scripttype="text/javascript"charset="utf-8"src="phonegap.0.9.5.js"></script>beforeallotherJavaScriptsothatitlooksasfollows(ifyouhavereplacedphonegap.0.9.5.jswithphonegap.0.9.4.js,pleaseusetheline<script<!DOCTYPE<!DOCTYPEHTMLPUBLIC
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025-2030全球電腦鎮(zhèn)痛泵行業(yè)調(diào)研及趨勢(shì)分析報(bào)告
- 2025-2030全球電動(dòng)汽車(chē)高壓直流繼電器行業(yè)調(diào)研及趨勢(shì)分析報(bào)告
- 2025年全球及中國(guó)IO-Link信號(hào)燈行業(yè)頭部企業(yè)市場(chǎng)占有率及排名調(diào)研報(bào)告
- 2025年全球及中國(guó)堆棧式CMOS圖像傳感器行業(yè)頭部企業(yè)市場(chǎng)占有率及排名調(diào)研報(bào)告
- 經(jīng)典居間合同
- 農(nóng)機(jī)作業(yè)服務(wù)合同
- 環(huán)保設(shè)施運(yùn)營(yíng)管理合同
- 熱長(zhǎng)期供貨合同
- 安全監(jiān)控系統(tǒng)集成服務(wù)合同
- 政府與企業(yè)合作協(xié)議
- 中醫(yī)診療設(shè)備種類(lèi)目錄
- 戰(zhàn)略管理與倫理
- 如何構(gòu)建高效課堂課件
- 徐金桂行政法與行政訴訟法新講義
- 瀝青拌合設(shè)備結(jié)構(gòu)認(rèn)知
- GB/T 13234-2018用能單位節(jié)能量計(jì)算方法
- (課件)肝性腦病
- 北師大版五年級(jí)上冊(cè)數(shù)學(xué)教學(xué)課件第5課時(shí) 人民幣兌換
- 工程回訪記錄單
- 高考物理二輪專(zhuān)題課件:“配速法”解決擺線問(wèn)題
- 檢驗(yàn)科生物安全風(fēng)險(xiǎn)評(píng)估報(bào)告
評(píng)論
0/150
提交評(píng)論