版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認(rèn)領(lǐng)
文檔簡介
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日注冊并開通網(wǎng)站,Liux現(xiàn)在已經(jīng)成為一種廣受關(guān)注和支持的一種操作系統(tǒng),ID中心,LinuxID就是關(guān)于inux的數(shù)據(jù)中心。并被收錄到Google網(wǎng)頁目錄-計算機>軟件>操作系統(tǒng)>Linux目錄下。Ubuntu專題Fedora專題RedHat專題紅旗LinuxAndroidLinux公社簡介-廣告服務(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. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2024試用期接觸勞動合同范本
- 供應(yīng)合同-省級國家機關(guān)、事業(yè)單位和社會團體計算機(或打印機)協(xié)議供貨合同
- 廣東省七年級上學(xué)期語文期中考試試卷5套【附答案】
- 2024年車輛物流運輸合同協(xié)議書
- 機械租賃合同模板集
- 展覽活動中的房產(chǎn)贈與合同
- 貨物倉儲出租協(xié)議
- 2024年詳細版租房協(xié)議書
- 手機銷售合同常見問題解答
- 2024版酒店經(jīng)營合作協(xié)議模板
- 干果加工項目建議書范文
- 人教版初中語文教材分析(課堂PPT)
- 護理核心制度督查表20179
- 紅色古色綠色文化教育活動策劃方案
- 《Monsters 怪獸》中英對照歌詞
- 《正交分解法》導(dǎo)學(xué)案
- 建筑材料知識點匯總
- 平面構(gòu)成作品欣賞
- 英語管道專業(yè)術(shù)語
- 社會工作畢業(yè)論文(優(yōu)秀范文8篇)
- 五篇500字左右的短劇劇本
評論
0/150
提交評論