android 系统编译要求,官方资料
2016-06-30 11:31
369 查看
Requirements
INTHISDOCUMENT
BeforeyoudownloadandbuildtheAndroidsource,ensureyoursystemmeetsthefollowingrequirements.ThenseeEstablishing
aBuildEnvironmentforinstallationinstructionsbyoperatingsystem.
Hardwarerequirements
Yourdevelopmentworkstationshouldmeetorexceedthesehardwarerequirements:A64-bitenvironmentisrequiredforGingerbread(2.3.x)andnewerversions,includingthemasterbranch.Youcancompileolderversionson32-bitsystems.
Atleast100GBoffreediskspaceforacheckout,150GBforasinglebuild,and200GBormoreformultiplebuilds.Ifyouemployccache,youwillneedevenmorespace.
IfyouarerunningLinuxinavirtualmachine,youneedatleast16GBofRAM/swap.
Softwarerequirements
Themasterbranch
istraditionallydevelopedandtestedonUbuntuLongTermSupport(LTS)releases,butotherdistributionsmaybeused.Seethelistbelowforrecommendedversions.
Youworkstationmusthavethesoftwarelistedbelow.SeeEstablishing
aBuildEnvironmentforadditionalrequiredpackagesandthecommandstoinstallthem.
Operatingsystem
AndroidistypicallybuiltwithaGNU/LinuxorMacOSoperatingsystem.ItisalsopossibletobuildAndroidinavirtualmachineonunsupportedsystemssuchasWindows.
GNU/Linux
Android6.0(Marshmallow)-AOSPmaster:Ubuntu14.04(Trusty)Android2.3.x(Gingerbread)-Android5.x(Lollipop):Ubuntu12.04(Precise)
Android1.5(Cupcake)-Android2.2.x(Froyo):Ubuntu10.04(Lucid)
MacOS(Intel/x86)
Android6.0(Marshmallow)-AOSPmaster:MacOSv10.10(Yosemite)orlaterwithXcode4.5.2andCommandLineToolsAndroid5.x(Lollipop):MacOSv10.8(MountainLion)withXcode4.5.2andCommandLineTools
Android4.1.x-4.3.x(JellyBean)-Android4.4.x(KitKat):MacOSv10.6(SnowLeopard)orMacOSXv10.7(Lion)andXcode4.2(Apple'sDeveloperTools)
Android1.5(Cupcake)-Android4.0.x(IceCreamSandwich):MacOSv10.5(Leopard)orMacOSXv10.6(SnowLeopard)andtheMacOSXv10.5SDK
JavaDevelopmentKit(JDK)
Pleasenote,sincetherearenoavailablesupportedOpenJDK8packagesforUbuntu14.04,theUbuntu15.04packagesmustbeinstalledmanually.SeeJDKforUbuntuLTS14.04forpreciseinstructions.
ThemasterbranchofAndroidinAOSP:Ubuntu-
8u45ornewer
Android5.x(Lollipop)-Android6.0(Marshmallow):Ubuntu-
Android2.3.x(Gingerbread)-Android4.4.x(KitKat):Ubuntu-Java
JDK6,MacOS-
Android1.5(Cupcake)-Android2.2.x(Froyo):Ubuntu-
Keypackages
Python2.6--2.7fromGNUMake3.81--3.82from
frommake3.82toavoidbuilderrors
Git1.7ornewerfrom
Devicebinaries
Downloadpreviews,factoryimages,drivers,over-the-air(OTA)updates,andotherblobsbelow.SeeObtainingproprietarybinariesforadditionaldetails.
masterbranch
development
EstablishingaBuildEnvironment
INTHISDOCUMENT
Setting
upaLinuxbuildenvironment
Installing
requiredpackages(Ubuntu14.04)
Installing
requiredpackages(Ubuntu12.04)
Installing
requiredpackages(Ubuntu10.04--11.10)
ConfiguringUSB
Access
Using
aseparateoutputdirectory
Setting
upaMacOSbuildenvironment
Creating
acase-sensitivediskimage
Installingthe
JDK
Optimizing
abuildenvironment(optional)
Next:Download
thesource
ThissectiondescribeshowtosetupyourlocalworkenvironmenttobuildtheAndroidsourcefiles.YouwillneedtouseLinuxorMacOS.BuildingunderWindowsisnotcurrentlysupported.
Foranoverviewoftheentirecode-reviewandcode-updateprocess,seeLife
ofaPatch.
ChoosingaBranch
Someoftherequirementsforyourbuildenvironmentaredeterminedbywhichversionofthesourcecodeyouplantocompile.SeeBuildNumbersforafulllistingofbranchesyoumaychoosefrom.Youmayalsochoosetodownloadandbuildthelatestsourcecode(called
master),inwhichcaseyouwillsimplyomitthe
branchspecificationwhenyouinitializetherepository.
Onceyouhaveselectedabranch,followtheappropriateinstructionsbelowtosetupyourbuildenvironment.
SettingupaLinuxbuildenvironment
Theseinstructionsapplytoallbranches,includingmaster.
TheAndroidbuildisroutinelytestedinhouseonrecentversionsofUbuntuLTS(14.04),butmostdistributionsshouldhavetherequiredbuildtoolsavailable.Reportsofsuccessesorfailuresonotherdistributions
arewelcome.
ForGingerbread(2.3.x)andnewerversions,includingthe
masterbranch,a64-bitenvironmentisrequired.Olderversionscanbecompiled
on32-bitsystems.
Note:Seethe
followthedetailedinstructionsforUbuntuandMacOSbelow.
InstallingtheJDK
ThemasterbranchofAndroidintheAndroid
OpenSourceProject(AOSP)requiresJava8.OnUbuntu,use
See
ForUbuntu>=15.04
Runthefollowing:$sudoapt-getupdate $sudoapt-getinstallopenjdk-8-jdk
ForUbuntuLTS14.04
TherearenoavailablesupportedOpenJDK8packagesforUbuntu14.04.TheUbuntu15.04OpenJDK8packageshavebeenusedsuccessfullywithUbuntu14.04.Newerpackageversions(e.g.thosefor15.10,16.04)werefoundnottoworkon14.04usingtheinstructionsbelow.
Downloadthe
.debpackagesfor64-bitarchitecturefrom
SHA256
0f5aba8db39088283b51e00054813063173a4d8809f70033976f83e214ab56c0
SHA256
9ef76c4562d39432b69baf6c18f199707c5c56a5b4566847df908b7d74e15849
SHA256
6e47215cf6205aa829e6a0a64985075bd29d1f428a4006a80c9db371c2fc3c4c
Optionally,confirmthechecksumsofthedownloadedfilesagainsttheSHA256stringlistedwitheachpackageabove.
Forexample,withthe
sha256sumtool:
$sha256sum{downloaded.debfile}
Installthepackages:
$sudoapt-getupdate
Run
dpkgforeachofthe.debfilesyoudownloaded.Itmayproduceerrorsduetomissingdependencies:
$sudodpkg-i{downloaded.debfile}
Tofixmissingdependencies:
$sudoapt-get-finstall
UpdatethedefaultJavaversion-optional
Optionally,fortheUbuntuversionsaboveupdatethedefaultJavaversionbyrunning:$sudoupdate-alternatives--configjava $sudoupdate-alternatives--configjavac
If,duringabuild,youencounterversionerrorsforJava,setitspathasdescribedintheWrong
JavaVersionsection.
Installingrequiredpackages(Ubuntu14.04)
Youwillneeda64-bitversionofUbuntu.Ubuntu14.04isrecommended.$sudoapt-getinstallgit-coregnupgflexbisongperfbuild-essential\ zipcurlzlib1g-devgcc-multilibg++-multiliblibc6-dev-i386\ lib32ncurses5-devx11proto-core-devlibx11-devlib32z-devccache\ libgl1-mesa-devlibxml2-utilsxsltprocunzip
Note:TouseSELinuxtoolsforpolicyanalysis,alsoinstallthe
python-networkxpackage.
Installingrequiredpackages(Ubuntu12.04)
YoumayuseUbuntu12.04tobuildolderversionsofAndroid.Version12.04isnotsupportedonmasterorrecentreleases.$sudoapt-getinstallgitgnupgflexbisongperfbuild-essential\ zipcurllibc6-devlibncurses5-dev:i386x11proto-core-dev\ libx11-dev:i386libreadline6-dev:i386libgl1-mesa-glx:i386\ libgl1-mesa-devg++-multilibmingw32tofrodos\ python-markdownlibxml2-utilsxsltproczlib1g-dev:i386 $sudoln-s/usr/lib/i386-linux-gnu/mesa/libGL.so.1/usr/lib/i386-linux-gnu/libGL.so
Installingrequiredpackages(Ubuntu10.04--11.10)
BuildingonUbuntu10.04-11.10isnolongersupported,butmaybeusefulforbuildingolderreleasesofAOSP.$sudoapt-getinstallgitgnupgflexbisongperfbuild-essential\ zipcurlzlib1g-devlibc6-devlib32ncurses5-devia32-libs\ x11proto-core-devlibx11-devlib32readline5-devlib32z-dev\ libgl1-mesa-devg++-multilibmingw32tofrodospython-markdown\ libxml2-utilsxsltproc
OnUbuntu10.10:
$sudoln-s/usr/lib32/mesa/libGL.so.1/usr/lib32/mesa/libGL.so
OnUbuntu11.10:
$sudoapt-getinstalllibx11-dev:i386
ConfiguringUSBAccess
UnderGNU/Linuxsystems(andspecificallyunderUbuntusystems),regularuserscan'tdirectlyaccessUSBdevicesbydefault.Thesystemneedstobeconfiguredtoallowsuchaccess.Therecommendedapproachistocreateafileat
/etc/udev/rules.d/51-android.rules(astherootuser).
Todothis,runthefollowingcommandtodownloadthe
attachedtothissite,modifyittoincludeyourusername,andplaceitinthecorrectlocation:
$wget-S-O-http://source.android.com/source/51-android.rules|sed"s/<username>/$USER/"|sudotee>/dev/null/etc/udev/rules.d/51-android.rules;sudoudevadmcontrol--reload-rules
Thosenewrulestakeeffectthenexttimeadeviceispluggedin.Itmightthereforebenecessarytounplugthedeviceandplugitbackintothecomputer.
Usingaseparateoutputdirectory
Bydefault,theoutputofeachbuildisstoredintheout/subdirectoryofthematchingsourcetree.
Onsomemachineswithmultiplestoragedevices,buildsarefasterwhenstoringthesourcefilesandtheoutputonseparatevolumes.Foradditionalperformance,theoutputcanbestoredonafilesystemoptimized
forspeedinsteadofcrashrobustness,sinceallfilescanbere-generatedincaseoffilesystemcorruption.
Tosetthisup,exportthe
OUT_DIR_COMMON_BASEvariabletopointtothelocationwhereyouroutputdirectorieswillbestored.
exportOUT_DIR_COMMON_BASE=<path-to-your-out-directory>
Theoutputdirectoryforeachseparatesourcetreewillbenamedafterthedirectoryholdingthesourcetree.
Forinstance,ifyouhavesourcetreesas
/source/master1and
/source/master2and
OUT_DIR_COMMON_BASEis
setto
/output,theoutputdirectorieswillbe
/output/master1and
/output/master2.
It'simportantinthatcasetonothavemultiplesourcetreesstoredindirectoriesthathavethesamename,asthosewouldendupsharinganoutputdirectory,withunpredictableresults.
ThisisonlysupportedonJellyBean(4.1)andnewer,includingthe
masterbranch.
SettingupaMacOSbuildenvironment
Inadefaultinstallation,MacOSrunsonacase-preservingbutcase-insensitivefilesystem.Thistypeoffilesystemisnotsupportedbygitandwillcausesomegitcommands(suchasgit status)tobehaveabnormally.Becauseofthis,werecommendthatyoualwaysworkwiththeAOSPsourcefilesonacase-sensitivefilesystem.Thiscanbedonefairlyeasilyusingadiskimage,discussedbelow.
Oncetheproperfilesystemisavailable,buildingthe
masterbranchinamodernMacOSenvironmentisverystraightforward.Earlierbranches,
includingICS,requiresomeadditionaltoolsandSDKs.
Creatingacase-sensitivediskimage
Youcancreateacase-sensitivefilesystemwithinyourexistingMacOSenvironmentusingadiskimage.Tocreatetheimage,launchDiskUtilityandselect"NewImage".Asizeof25GBistheminimumtocompletethebuild;largernumbersaremorefuture-proof.Usingsparseimagessavesspacewhileallowingtogrowlaterastheneedarises.Besuretoselect"casesensitive,journaled"asthevolumeformat.
Youcanalsocreateitfromashellwiththefollowingcommand:
#hdiutilcreate-typeSPARSE-fs'Case-sensitiveJournaledHFS+'-size40g~/android.dmg
Thiswillcreatea
.dmg(orpossiblya
.dmg.sparseimage)filewhich,
oncemounted,actsasadrivewiththerequiredformattingforAndroiddevelopment.
Ifyouneedalargervolumelater,youcanalsoresizethesparseimagewiththefollowingcommand:
#hdiutilresize-size<new-size-you-want>g~/android.dmg.sparseimage
Foradiskimagenamed
android.dmgstoredinyourhomedirectory,youcanaddhelperfunctionstoyour
~/.bash_profile:
Tomounttheimagewhenyouexecute
mountAndroid:
#mounttheandroidfileimage functionmountAndroid{hdiutilattach~/android.dmg-mountpoint/Volumes/android;}
Note:Ifyoursystemcreateda
.dmg.sparseimagefile,replace
~/android.dmgwith
~/android.dmg.sparseimage.
Tounmountitwhenyouexecute
umountAndroid:
#unmounttheandroidfileimage functionumountAndroid(){hdiutildetach/Volumes/android;}
Onceyou'vemountedthe
androidvolume,you'lldoallyourworkthere.Youcanejectit(unmountit)justlikeyouwouldwithanexternal
drive.
InstallingtheJDK
SeevariousversionsofAndroid.
Installingrequiredpackages
InstallXcodefromdeveloper,youwillhavetocreateanAppleIDinordertodownload.
InstallMacPortsfrom
Note:Makesurethat
/opt/local/binappearsinyourpathbefore
/usr/bin.If
not,pleaseaddthefollowingtoyour
~/.bash_profilefile:
exportPATH=/opt/local/bin:$PATH
Note:Ifyoudonothavea
.bash_profilefileinyourhomedirectory,createone.
Getmake,git,andGPGpackagesfromMacPorts:
$POSIXLY_CORRECT=1sudoportinstallgmakelibsdlgitgnupg
IfusingMacOSXv10.4,alsoinstallbison:
$POSIXLY_CORRECT=1sudoportinstallbison
Revertingfrommake3.82
InAndroid4.0.x(IceCreamSandwich)andearlier,abugexistsingmake3.82thatpreventsandroidfrombuilding.Youcaninstallversion3.81usingMacPortswiththesesteps:Edit
/opt/local/etc/macports/sources.confandaddalinethatsays
file:///Users/Shared/dports
abovethersyncline.Thencreatethisdirectory:
$mkdir/Users/Shared/dports
Inthenew
dportsdirectory,run
$svnco--revision50980http://svn.macports.org/repository/macports/trunk/dports/devel/gmake/devel/gmake/
Createaportindexforyournewlocalrepository:
$portindex/Users/Shared/dports
Finally,installtheoldversionofgmakewith
$sudoportinstallgmake@3.81
Settingafiledescriptorlimit
OnMacOS,thedefaultlimitonthenumberofsimultaneousfiledescriptorsopenistoolowandahighlyparallelbuildprocessmayexceedthislimit.Toincreasethecap,addthefollowinglinestoyour
~/.bash_profile:
#setthenumberofopenfilestobe1024 ulimit-S-n1024
Optimizingabuildenvironment(optional)
Settingupccache
Youcanoptionallytellthebuildtousetheccachecompilationtool,whichisacompilercacheforCandC++thatcanhelpmakebuildsfaster.Itisespeciallyusefulforbuildserversandotherhigh-volumeproductionenvironments.Ccacheactsasacompilercachethatcanbeusedtospeeduprebuilds.Thisworksverywellifyouuse
makecleanoften,orifyoufrequentlyswitchbetweendifferentbuild
products.
Note:Ifyou'reinsteadconductingincrementalbuilds(suchasanindividualdeveloperratherthanabuildserver),ccachemayslowyourbuildsdownbymakingyoupayforcachemisses.
Touseccache,issuethesecommandsintherootofthesourcetree:
$exportUSE_CCACHE=1 $exportCCACHE_DIR=/<path_of_your_choice>/.ccache $prebuilts/misc/linux-x86/ccache/ccache-M50G
Thesuggestedcachesizeis50-100G.
Putthefollowinginyour
.bashrc(orequivalent):
exportUSE_CCACHE=1
Bydefaultthecachewillbestoredin
~/.ccache.IfyourhomedirectoryisonNFSorsomeothernon-localfilesystem,youwillwanttospecify
thedirectoryinyour
.bashrcfiletoo.
OnMacOS,youshouldreplace
linux-x86with
darwin-x86:
$prebuilts/misc/darwin-x86/ccache/ccache-M50G
WhenbuildingIceCreamSandwich(4.0.x)orolder,ccacheisinadifferentlocation:
prebuilt/linux-x86/ccache/ccache-M50G
ThissettingisstoredintheCCACHE_DIRandispersistent.
OnLinux,youcanwatchccachebeingusedbydoingthefollowing:
$watch-n1-dprebuilts/misc/linux-x86/ccache/ccache-s
Next:Downloadthesource
Yourbuildenvironmentisgoodtogo!Proceedtodownloadcode
PreparingtoBuild
INTHISDOCUMENT
Obtainproprietarybinaries
Download
proprietarybinaries
Extractproprietary
binaries
EmulateanAndroid
Device
Troubleshooting
CommonBuildErrors
CaseInsensitive
Filesystem
ThefollowinginstructionstobuildtheAndroidsourcetreeapplytoallbranches,including
master.Thebasicsequenceofbuildcommands
isasfollows:
Note:Ifyou'rebuildingAndroid6.0orlater,pleasesee
newdefaulttoolchain.
Obtainproprietarybinaries
AOSPcannotbeusedfrompuresourcecodeonlyandrequiresadditionalhardware-relatedproprietarylibrariestorun,suchasforhardwaregraphicsacceleration.SeethesectionsbelowfordownloadlinksandDevicebinariesrequirementsforadditionalresources.
Downloadproprietarybinaries
YoucandownloadofficialbinariesforthesupporteddevicesrunningtaggedAOSPreleasebranchesfromGoogle'sNexusdriverpage.Thesebinariesaddaccesstoadditionalhardwarecapabilitieswithnon-opensourcecode.ToinsteadbuildtheAOSPmasterbranch,usetheBinaries
PreviewforNexusDevices.Whenbuildingthemasterbranchforadevice,usethebinariesforthemostrecent
numberedreleaseorwiththemostrecentdate.
Extractproprietarybinaries
Eachsetofbinariescomesasaself-extractingscriptinacompressedarchive.Uncompresseacharchive,runtheincludedself-extractingscriptfromtherootofthesourcetree,thenconfirmthatyouagreetothetermsoftheenclosedlicenseagreement.Thebinariesandtheirmatchingmakefileswillbeinstalledinthe
vendor/hierarchyofthesourcetree.
Cleanup
Toensurethenewlyinstalledbinariesareproperlytakenintoaccountafterbeingextracted,deletetheexistingoutputofanypreviousbuildusing:$makeclobber
Setupenvironment
Initializetheenvironmentwiththeenvsetup.shscript.Notethatreplacing
sourcewith
.(a
singledot)savesafewcharacters,andtheshortformismorecommonlyusedindocumentation.
$sourcebuild/envsetup.sh
or
$.build/envsetup.sh
Chooseatarget
Choosewhichtargettobuildwithlunch.Theexactconfigurationcanbepassedasanargument.Forexample,thefollowingcommand:
$lunchaosp_arm-eng
referstoacompletebuildfortheemulator,withalldebuggingenabled.
Ifrunwithnoarguments
lunchwillpromptyoutochooseatargetfromthemenu.
Allbuildtargetstaketheform
BUILD-BUILDTYPE,wherethe
BUILDis
acodenamereferringtotheparticularfeaturecombination.
TheBUILDTYPEisoneofthefollowing:
Buildtype | Use |
---|---|
user | limitedaccess;suitedforproduction |
userdebug | like"user"butwithrootaccessanddebuggability;preferredfordebugging |
eng | developmentconfigurationwithadditionaldebuggingtools |
Builds.
Buildthecode
Pleasenote,thissectionismerelyasummarytoensuresetupiscomplete.SeeRunningBuildsfordetailedinstructionsonbuildingAndroid.
Buildeverythingwith
make.GNUmakecanhandleparalleltaskswitha
-jNargument,
andit'scommontouseanumberoftasksNthat'sbetween1and2timesthenumberofhardwarethreadsonthecomputerbeingusedforthebuild.Forexample,onadual-E5520machine(2CPUs,4coresperCPU,2threadspercore),thefastestbuildsaremade
withcommandsbetween
make-j16and
make-j32.
$make-j4
Runit!
Youcaneitherrunyourbuildonanemulatororflashitonadevice.Pleasenotethatyouhavealreadyselectedyourbuildtargetwithlunch,
anditisunlikelyatbesttorunonadifferenttargetthanitwasbuiltfor.
Note:Rememberto
notbootsuccessfullyonyourtargethardware.Ifyouobtainbinaryblobsatthispointyouwillneedtounpackthem,
makeclobberandrebuild.
Flashwithfastboot
Toflashadevice,youwillneedtousefastboot,whichshouldbeincludedinyourpathafterasuccessfulbuild.SeeFlashing
adeviceforinstructions.
EmulateanAndroidDevice
Theemulatorisaddedtoyourpathautomaticallybythebuildprocess.Toruntheemulator,type:$emulator
TroubleshootingCommonBuildErrors
WrongJavaVersion
IfyouareattemptingtobuildaversionofAndroidinconsistentwithyourversionofJava,makewillabortwithamessagesuchas
************************************************************ Youareattemptingtobuildwiththeincorrectversion ofjava. Yourversionis:WRONG_VERSION. Thecorrectversionis:RIGHT_VERSION. Pleasefollowthemachinesetupinstructionsathttps://source.android.com/source/initializing.html************************************************************
Thismaybecausedby:
FailingtoinstallthecorrectJDKasspecifiedin
AnotherJDKpreviouslyinstalledappearinginyourpath.PrependthecorrectJDKtothebeginningofyourPATHorremovetheproblematicJDK.
PythonVersion3
RepoisbuiltonparticularfunctionalityfromPython2.xandisunfortunatelyincompatiblewithPython3.Inordertouserepo,pleaseinstallPython2.x:$apt-getinstallpython
CaseInsensitiveFilesystem
IfyouarebuildingonanHFSfilesystemonMacOS,youmayencounteranerrorsuchas************************************************************ Youarebuildingonacase-insensitivefilesystem. Pleasemoveyoursourcetreetoacase-sensitivefilesystem. ************************************************************
Pleasefollowtheinstructionsin
creatingacase-sensitivediskimage.
NoUSBPermission
OnmostLinuxsystems,unprivilegeduserscannotaccessUSBportsbydefault.Ifyouseeapermissiondeniederror,followtheinstructionsInitializingtheBuildEnvironmentforconfiguringUSBaccess.
Ifadbwasalreadyrunningandcannotconnecttothedeviceaftergettingthoserulessetup,itcanbekilledwith
adbkill-server.That
willcauseadbtorestartwiththenewconfiguration.
CompilingwithJack
INTHISDOCUMENT
UsingJackin
yourAndroidbuild
TheJacktoolchain
JackisanewAndroidtoolchainthatcompilesJavasourceintoAndroiddexbytecode.ItreplacesthepreviousAndroidtoolchain,whichconsistsofmultipletools,suchasjavac,ProGuard,jarjar,anddx.TheJacktoolchainprovidesthefollowingadvantages:
Completelyopensource
AvailableinAOSP;partnersarewelcometocontribute.
Speedscompilationtime
Jackhasspecificsupportstoreducecompilationtime:pre-dexing,incrementalcompilationandaJackcompilationserver.
Handlesshrinking,obfuscation,repackagingandmultidex
UsingaseparatepackagesuchasProGuardisnolongernecessary.
Figure1.Jackoverview
The.jacklibraryformat
Jackhasitsown.jackfileformat,whichcontainsthepre-compileddexcodeforthelibrary,allowingforfastercompilation(pre-dex).Figure2.Jacklibraryfilecontents
Jill
TheJilltooltranslatestheexisting.jarlibrariesintothenewlibraryformat,asshownbelow.Figure3.Workflowtoimportanexisting.jarlibrary
UsingJackinyourAndroidbuild
Youdon’thavetodoanythingdifferentlytouseJack—justuseyourstandardmakefilecommandstocompilethetreeoryourproject.JackisthedefaultAndroidbuildtoolchainforM.ThefirsttimeJackisused,itlaunchesalocalJackcompilationserveronyourcomputer:
Thisserverbringsanintrinsicspeedup,becauseitavoidslaunchinganewhostJREJVM,loadingJackcode,initializingJackandwarminguptheJITateachcompilation.Italsoprovidesverygoodcompilationtimesduringsmall
compilations(e.g.inincrementalmode).
Theserverisalsoashort-termsolutiontocontrolthenumberofparallelJackcompilations,andsotoavoidoverloadingyourcomputer(memoryordiskissue),becauseitlimitsthenumberofparallelcompilations.
TheJackservershutsitselfdownafteranidletimewithoutanycompilation.ItusestwoTCPportsonthelocalhostinterface,andsoisnotavailableexternally.Alltheseparameters(numberofparallelcompilations,
timeout,portsnumber,etc)canbemodifiedbyeditingthe
$HOME/.jackfile.
$HOME/.jackfile
The$HOME/.jackfilecontainssettingsforJackservervariables,inafullbashsyntax.
Herearetheavailablesettings,withtheirdefinitionsanddefaultvalues:
SERVER=trueEnabletheserverfeatureof
Jack.
SERVER_PORT_SERVICE=8072SettheTCPportnumberoftheserverforcompilationpurposes.
SERVER_PORT_ADMIN=8073SettheTCPportnumberoftheserverforadminpurposes.
SERVER_COUNT=1Unusedatpresent.
SERVER_NB_COMPILE=4Maximumnumberofparallelcompilationsallowed.
SERVER_TIMEOUT=60Numberofidlesecondstheserverhastowaitwithoutanycompilationbeforeshuttingitselfdown.
SERVER_LOG=${SERVER_LOG:=$SERVER_DIR/jack-$SERVER_PORT_SERVICE.log}Filewhereserverlogsarewritten.Bydefault,
thisvariablecanbeoverloadedbyanenvironmentvariable.
JACK_VM_COMMAND=${JACK_VM_COMMAND:=java}ThedefaultcommandusedtolaunchaJVMonthehost.Bydefault,thisvariable
canbeoverloadedbyenvironmentvariable.
Jacktroubleshooting
IfyourcomputerbecomesunresponsiveduringcompilationorifyouexperienceJackcompilationsfailingon“Outofmemoryerror”YoucanimprovethesituationbyreducingthenumberofJacksimultaneouscompilationsbyeditingyour
$HOME/.jackandchanging
SERVER_NB_COMPILEto
alowervalue.
Ifyourcompilationsarefailingon“Cannotlaunchbackgroundserver”
ThemostlikelycauseisTCPportsarealreadyusedonyourcomputer.Trytochangeitbyeditingyour
$HOME/.jack(
SERVER_PORT_SERVICEand
SERVER_PORT_ADMINvariables).
Ifitdoesn’tsolvetheproblem,pleasereportandattachyourcompilationlogandtheJackserverlog(see‘FindingtheJacklog’belowtoknowwheretofindtheserverlogfile).Tounblockthesituation,disable
jackcompilationserverbyeditingyour
$HOME/.jackandchanging
SERVERtofalse.Unfortunatelythiswillsignificantly
slowdownyourcompilationandmayforceyoutolaunch
make-jwithloadcontrol(option"
-l"of
make).
Ifyourcompilationgetsstuckwithoutanyprogress
Pleasereportthisandgiveusthefollowingadditionalinformation(wherepossible):
Thecommandlineatwhichyouarestuck.
Theoutputofthiscommandline.
Theresultofexecuting
jack-adminserver-stat.
The
$HOME/.jackfile.
Thecontentoftheserverlogwiththeserverstatedumped.Togetthis—
FindtheJackbackgroundserverprocessbyrunning
jack-adminlist-server.
Senda
kill-3commandtothisservertodumpitsstateintothelogfile.
Tolocatetheserverlogfile,see‘FindingtheJacklog’below.
Theresultofexecuting
ls-lR$TMPDIR/jack-$USER.
Theresultofrunning
psj-U$USER.
YoushouldbeabletounblockyourselfbykillingtheJackbackgroundserver(use
jack-adminkill-server),andthenbyremovingitstemporary
directoriescontainedin
jack-$USERofyourtemporarydirectory(
/tmpor
$TMPDIR).
Ifyouhaveanyotherissues
Toreportbugsorrequestfeatures,pleaseuseourpublicissuetracker,availableat
withthe
toolfeaturerequesttemplates.PleaseattachtheJacklogtothebugreport.
FindingtheJacklog Ifyouranamakecommandwithadisttarget,theJacklogislocatedat $ANDROID_BUILD_TOP/out/dist/logs/jack-server.log Otherwiseyoucanfinditinbyrunning jack-adminserver-log |
$exportANDROID_JACK_EXTRA_ARGS="--verbosedebug--sanity-checkson-D
sched.runner=single-threaded"
Thenuseyourstandardmakefilecommandstocompilethetreeoryourprojectandattachitsstandardoutputanderror.
Toremovedetailedbuildlogsuse:
$unsetANDROID_JACK_EXTRA_ARGS
Jacklimitations
TheJackserverismono-userbydefault,socanbeonlyusedbyoneuseronacomputer.Ifitisnotthecase,please,choosedifferentportnumbersforeachuserandadjustSERVER_NB_COMPILEaccordingly.YoucanalsodisabletheJackserverbysettingSERVER=falseinyour$HOME/.jack.
CTScompilationisslowduetocurrentvm-tests-tfintegration.
Bytecodemanipulationtools,likeJaCoCo,arenotsupported.
UsingJackfeatures
JacksupportsJavaprogramminglanguage1.7andintegratesadditionalfeaturesdescribedbelow.
Predexing
WhengeneratingaJacklibraryfile,the.dexofthelibraryisgeneratedandstoredinsidethe.jacklibraryfileasapre-dex.Whencompiling,Jackreusesthepre-dexfromeachlibrary.Alllibrariesarepre-dexed.
Figure4.Jacklibrarieswithpre-dex
Limitations
Currently,Jackdoesnotreusethelibrarypre-dexifshrinking/obfuscation/repackagingisusedinthecompilation.
Incrementalcompilation
Incrementalcompilationmeansthatonlycomponentsthatweretouchedsincethelastcompilation,andtheirdependencies,arerecompiled.Incrementalcompilationcanbesignificantlyfasterthanafullcompilationwhenchangesarelimitedtoonlyalimitedsetofcomponents.
Limitations
Incrementalcompilationisdeactivatedwhenshrinking,obfuscation,repackagingormulti-dexlegacyisenabled.
Enablingincrementalbuilds
Currentlyincrementalcompilationisnotenabledbydefault.Toenableincrementalbuilds,addthefollowinglinetotheAndroid.mkfileoftheprojectthatyouwanttobuildincrementally:LOCAL_JACK_ENABLED:=incremental
Note:ThefirsttimethatyoubuildyourprojectwithJackifsomedependenciesarenotbuilt,use
mmatobuildthem,andafterthatyoucanusethestandardbuildcommand.
ShrinkingandObfuscation
Jackhasshrinkingandobfuscationsupportandusesproguardconfigurationfilestoenableshrinkingandobfuscationfeatures.Herearethesupportedandignoredoptions:
Supportedcommonoptions
Commonoptionsincludethefollowing:@
-include
-basedirectory
-injars
-outjars//only1outputjarsupported
-libraryjars
-keep
-keepclassmembers
-keepclasseswithmembers
-keepnames
-keepclassmembernames
-keepclasseswithmembernames
-printseeds
Supportedshrinkingoptions
Shrinkingoptionsincludethefollowing:-dontshrink
Supportedobfuscationoptions
Obfuscationoptionsincludethefollowing:-dontobfuscate
-printmapping
-applymapping
-obfuscationdictionary
-classobfuscationdictionary
-packageobfuscationdictionary
-useuniqueclassmembernames
-dontusemixedcaseclassnames
-keeppackagenames
-flattenpackagehierarchy
-repackageclasses
-keepattributes
-adaptclassstrings
Ignoredoptions
Ignoredoptionsincludethefollowing:-dontoptimize//Jackdoesnotoptimize
-dontpreverify//Jackdoesnotpreverify
-skipnonpubliclibraryclasses
-dontskipnonpubliclibraryclasses
-dontskipnonpubliclibraryclassmembers
-keepdirectories
-target
-forceprocessing
-printusage
-whyareyoukeeping
-optimizations
-optimizationpasses
-assumenosideeffects
-allowaccessmodification
-mergeinterfacesaggressively
-overloadaggressively
-microedition
-verbose
-dontnote
-dontwarn
-ignorewarnings
-printconfiguration
-dump
Note:Otheroptionswillgenerateanerror.
Repackaging
Jackusesjarjarconfigurationfilestodotherepackaging.Note:Jackiscompatiblewith"rule"ruletypes,butisnotcompatiblewith"zap"or"keep"ruletypes.Ifyouneed"zap"or"keep"ruletypespleasefileafeaturerequestwithadescriptionofhowyouusethefeatureinyourapp.
Multidexsupport
Sincedexfilesarelimitedto65Kmethods,appswithover65Kmethodsmustbesplitintomultipledexfiles.(See‘BuildingAppswithOver65KMethods’formoreinformationaboutmultidex.)
Jackoffersnativeandlegacymultidexsupport.
SelectingDevices
INTHISDOCUMENT
Installinginitial
fastbootandptable
Configuringkernelserial
output(uart3)
YoucancreatebuildsforNexusdevicesusingAndroidOpenSourceProject(AOSP)buildsandtherelevanthardware-specificbinaries.ForavailableAndroidbuildsandtargetedNexusdevices,seeSource
Code,Tags,andBuilds.
Note:Duetohardwaredifferences,donotuseAndroid4.1.1onaNexus7originallysoldwithAndroid4.1.2ornewer.
Youcanalsocreatebuildsforthe
board(describedbelow).Referenceboardsaredesignedtohelpnon-NexuscomponentvendorsdevelopandportdriverstoAndroidreleases.Usingareferenceboardcaneaseupgradeefforts,reducetime-to-marketfornewAndroiddevices,lowerdevicecostsby
enablingODM/OEMstochoosefromawiderrangeofcompatiblecomponents,andincreasethespeedofinnovationamongcomponentsuppliers.
HiKeyboards
GooglesupportsasanAndroidreferenceboard.AOSPprovideskernelsourceandboardsupportforHiKeytoenabledeveloperstoeasilycreateanddebugnewandexistingperipheraldrivers,dokerneldevelopment,andperformothertaskswithfewerOEMencumbrances.
HiKeyboardsareavailablein
RAMconfigurationsfrom
Figure1.HiKeyboardbyLenovator
Additionalresources:
RunningAndroidonHiKey
Usethefollowingcommandstodownload,build,andrunAndroidonaHiKeyboard.
Compilinguserspace
DownloadtheAndroidsourcetree:$repoinit-uhttps://android.googlesource.com/platform/manifest-bmaster
$reposync-j24
DownloadandextractHDMIbinariesintotheAndroidsourcetree:
$wgethttps://dl.google.com/dl/android/aosp/linaro-hikey-20160226-67c37b1a.tgz
$tarxzflinaro-hikey-20160226-67c37b1a.tgz
$./extract-linaro-hikey.sh
Installmcopyutility:
$apt-getinstallmtools
Build:
$../build/envsetup.sh
$lunchhikey-userdebug
$make-j32
Note:For4GBeMMC,insteadof
$make-j32use:
$make-j32TARGET_USERDATAIMAGE_4GB=true.
Installinginitialfastbootandptable
SelectspecialbootloadermodebylinkingJ151-2and3-4pins(fordetails,refertotheHiKeyUserGuide).
ConnectUSBtoPCtogetttyUSBdevice(ex:
/dev/ttyUSB1).
Powertheboard:
$cddevice/linaro/hikey/installer
$./flash-all.sh/dev/ttyUSB1[4g]
Removejumper3-4andpowertheboard.
Flashingimages
EnterfastbootmodebylinkingJ151-2and5-6pins.Runthefollowingcommands:
$fastbootflashbootout/target/product/hikey/boot.img
$fastbootflash-wsystemout/target/product/hikey/system.img
Removejumper5-6andpowertheboard.
Buildingthekernel
Runthefollowingcommands:$gitclonehttps://android.googlesource.com/kernel/hikey-linaro
$cdhikey-linaro
$gitcheckout-bandroid-hikey-linaro-4.4origin/android-hikey-linaro-4.4
$makeARCH=arm64hikey_defconfig
$makeARCH=arm64CROSS_COMPILE=aarch64-linux-android--j24
Copyoutputtothehikeykerneldirectory(
/kernel/hikey-linaro):
Copyhi6220-hikey.dtb(
arch/arm64/boot/dts/hisilicon/hi6220-hikey.dtb)tothehikey-kerneldirectory.
CopytheImagefile
(arch/arm64/boot/Image-dtb)tothehikey-kerneldirectory.
Makethebootimage:
$makebootimage-j24
Settingmonitorresolution
Editdevice/linaro/hikey/BoardConfig.mkparameter
BOARD_KERNEL_CMDLINEand
configurethe
videosetting.Examplesettingfora24"monitor:
video=HDMI-A-1:1280x800@60.
Configuringkernelserialoutput(uart3)
SettheJ2lowspeedexpansionconnectorto1-Gnd,11-Rx,13-Tx.Fordetails,refertotheHiKeyUserGuide).
RunningBuilds
INTHISDOCUMENT
Buildingfastbootandadb
Bootingintofastboot
mode
Restoring
devicestofactorystate
ThispageprovidesdetailsforrunningbuildsonspecificdevicesandisdesignedtocomplementtheinformationinBuilding
theSystem.
Buildingfastbootandadb
Ifyoudon'talreadyhavefastbootandadb,youcanbuildthemwiththeregularbuildsystem.UsetheinstructionsinBuildingaSystemandreplacethemain
makecommandwith:
$makefastbootadb
Bootingintofastbootmode
Duringacoldbootofadevice,usethefollowingkeycombinationstobootintofastbootmode,whichisamodeinthebootloaderthatcanbeusedtoflashthedevice:Device | Keys |
---|---|
hikey | Linkpins1-2and5-6ofJ15 |
angler | PressandholdVolumeDown,thenpressandholdPower |
bullhead | PressandholdVolumeDown,thenpressandholdPower |
shamu | PressandholdVolumeDown,thenpressandholdPower |
fugu | PressandholdPower |
volantis | PressandholdVolumeDown,thenpressandholdPower |
hammerhead | PressandholdbothVolumeUpandVolumeDown,thenpressandholdPower |
flo | PressandholdVolumeDown,thenpressandholdPower |
deb | PressandholdVolumeDown,thenpressandholdPower |
manta | PressandholdbothVolumeUpandVolumeDown,thenpressandholdPower |
mako | PressandholdVolumeDown,thenpressandholdPower |
grouper | PressandholdVolumeDown,thenpressandholdPower |
tilapia | PressandholdVolumeDown,thenpressandholdPower |
phantasm | Powerthedevice,coveritwithonehandaftertheLEDslightupanduntiltheyturnred |
maguro | PressandholdbothVolumeUpandVolumeDown,thenpressandholdPower |
toro | PressandholdbothVolumeUpandVolumeDown,thenpressandholdPower |
toroplus | PressandholdbothVolumeUpandVolumeDown,thenpressandholdPower |
panda | PressandholdInput,thenpressPower |
wingray | PressandholdVolumeDown,thenpressandholdPower |
crespo | PressandholdVolumeUp,thenpressandholdPower |
crespo4g | PressandholdVolumeUp,thenpressandholdPower |
adbrebootbootloadertorebootfromAndroiddirectlyintothebootloaderwithnokeycombinations.
Unlockingthebootloader
It'spossibletoflashacustomsystemonlyifthebootloaderallowsit,andthebootloaderislockedbydefault.Youcanunlockthebootloader,butbeawarethatdoingsodeletestheuserdataforprivacyreasons(theunlockoperationneedstorunonlyonce).Afterunlocking,alldataonthedeviceiserased,i.e.boththeapplications'privatedataandtheshareddatathatisaccessibleoverUSB,includingphotosandmovies.Besuretobackupanypreciousfilesbefore
unlockingthebootloader.
Withthedeviceinfastbootmode,unlockthebootloaderusing:
$fastbootoemunlock
Theproceduremustbeconfirmedon-screen.
OnNexus10,afterunlockingthebootloader,theinternalstorageremainsunformatted.Youcanformatthedeviceusing:
$fastbootformatcache
$fastbootformatuserdata
Tore-lockthebootloader,use:
$fastbootoemlock
Note:Re-lockingthebootloadingonaMotoroalXoomerasesuserdata(includingthesharedUSBdata).
Selectingadevicebuild
Therecommendedbuildsfordevicesareavailablefromthelunchmenu,accessedwhenrunningthelunchcommandwithnoarguments.Youcandownload
factoryimagesandbinariesforNexusdevicesfromdevelopers.google.com:
See
moredetailsand
Device | Codename | Buildconfiguration |
---|---|---|
HiKey | hikey | hikey-userdebug |
Nexus6P | angler | aosp_angler-userdebug |
Nexus5X | bullhead | aosp_bullhead-userdebug |
Nexus6 | shamu | aosp_shamu-userdebug |
NexusPlayer | fugu | aosp_fugu-userdebug |
Nexus9 | volantis(flounder) | aosp_flounder-userdebug |
Nexus5(GSM/LTE) | hammerhead | aosp_hammerhead-userdebug |
Nexus7(Wi-Fi) | razor(flo) | aosp_flo-userdebug |
Nexus7(Mobile) | razorg(deb) | aosp_deb-userdebug |
Nexus10 | mantaray(manta) | full_manta-userdebug |
Nexus4 | occam(mako) | full_mako-userdebug |
Nexus7(Wi-Fi) | nakasi(grouper) | full_grouper-userdebug |
Nexus7(Mobile) | nakasig(tilapia) | full_tilapia-userdebug |
GalaxyNexus(GSM/HSPA+) | yakju(maguro) | full_maguro-userdebug |
GalaxyNexus(Verizon) | mysid(toro) | aosp_toro-userdebug |
GalaxyNexus(Experimental) | mysidspr(toroplus) | aosp_toroplus-userdebug |
PandaBoard(Archived) | panda | aosp_panda-userdebug |
MotorolaXoom(U.S.Wi-Fi) | wingray | full_wingray-userdebug |
NexusS | soju(crespo) | full_crespo-userdebug |
NexusS4G | sojus(crespo4g) | full_crespo4g-userdebug |
Flashingadevice
YoucanflashanentireAndroidsysteminasinglecommand;doingsoverifiesthesystembeingflashediscompatiblewiththeinstalledbootloaderandradio,writestheboot,recovery,andsystempartitionstogether,andthenrebootsthesystem.Flashingalsoerasesalluserdata,similarlyto
fastbootoemunlock.
Placethedeviceinfastbootmodeeithermanuallybyholdingtheappropriatekeycombinationatboot,orfromtheshellwith:
$adbrebootbootloader
Oncethedeviceisinfastbootmode,run:
$fastbootflashall-w
The
-woptionwipesthe
/datapartitiononthedevice;thisis
usefulforyourfirsttimeflashingaparticulardevicebutisotherwiseunnecessary.
Note:FilesystemscreatedviafastbootonMotorolaXoomdonotfunctionoptimally.Werecommendre-creatingfilesystemsthroughrecovery,using:
$adbrebootrecovery.
Whileinrecovery,openthemenu(pressPower+VolumeUp),wipethecachepartition,thenwipedata.
Restoringdevicestofactorystate
FactoryimagesforNexus5,Nexus10,Nexus4,NexusQ,Nexus7,GalaxyNexus(GSM/HSPA+"yakju"and"takju",andCDMA/LTE"mysid"and"mysidspr"),NexusS,andNexusS4GareavailablefromGoogle'sfactoryimagepage.
FactoryimagesfortheMotorolaXoomaredistributeddirectlybyMotorola.
BuildingKernels
INTHISDOCUMENT
Selectingakernel
Downloading
aprebuiltgcc
Thispagedetailshowtobuildonlythekernel.ThefollowinginstructionsassumeyouhavenotdownloadedallofAOSP;ifyouhavealreadydoneso,youcanskipthe
git clonestepsexceptthestepthatdownloadsthekernelsources.
Allexamplesinthissectionusethe
Selectingakernel
Thistableliststhenameandlocationsofthekernelsourcesandbinaries:Device | Binarylocation | Sourcelocation | Buildconfiguration |
---|---|---|---|
hikey | device/linaro/hikey-kernel | kernel/hikey-linaro | hikey_defconfig |
angler | device/huawei/angler-kernel | kernel/msm | angler_defconfig |
bullhead | device/lge/bullhead-kernel | kernel/msm | bullhead_defconfig |
shamu | device/moto/shamu-kernel | kernel/msm | shamu_defconfig |
fugu | device/asus/fugu-kernel | kernel/x86_64 | fugu_defconfig |
volantis | device/htc/flounder-kernel | kernel/tegra | flounder_defconfig |
hammerhead | device/lge/hammerhead-kernel | kernel/msm | hammerhead_defconfig |
flo | device/asus/flo-kernel/kernel | kernel/msm | flo_defconfig |
deb | device/asus/flo-kernel/kernel | kernel/msm | flo_defconfig |
manta | device/samsung/manta/kernel | kernel/exynos | manta_defconfig |
mako | device/lge/mako-kernel/kernel | kernel/msm | mako_defconfig |
grouper | device/asus/grouper/kernel | kernel/tegra | tegra3_android_defconfig |
tilapia | device/asus/grouper/kernel | kernel/tegra | tegra3_android_defconfig |
maguro | device/samsung/tuna/kernel | kernel/omap | tuna_defconfig |
toro | device/samsung/tuna/kernel | kernel/omap | tuna_defconfig |
panda | device/ti/panda/kernel | kernel/omap | panda_defconfig |
stingray | device/moto/wingray/kernel | kernel/tegra | stingray_defconfig |
wingray | device/moto/wingray/kernel | kernel/tegra | stingray_defconfig |
crespo | device/samsung/crespo/kernel | kernel/samsung | herring_defconfig |
crespo4g | device/samsung/crespo/kernel | kernel/samsung | herring_defconfig |
device/<vendor>/<name>.
$gitclonehttps://android.googlesource.com/kernel/hikey-linaro$cdhikey-linaro
$gitlog--max-count=1kernel
Thecommitmessageforthekernelbinarycontainsapartialgitlogofthekernelsourcesusedtobuildthebinary.Thefirstentryinthelogisthemostrecent(theoneusedtobuildthekernel).Makeanoteof
thecommitmessageasyouwillneeditinalaterstep.
Identifyingkernelversion
Todeterminethekernelversionusedinasystemimage,runthefollowingcommandagainstthekernelfile:$ddif=kernelbs=1skip=$(LC_ALL=Cgrep-a-b-o$'\x1f\x8b\x08\x00\x00\x00\x00\x00'kernel|cut-d':'-f1)|zgrep-a'Linuxversion'
ForNexus5(hammerhead),thecommandis:
$ddif=zImage-dtbbs=1skip=$(LC_ALL=Cod-Ad-x-w2zImage-dtb|grep8b1f|cut-d''-f1|head-1)|zgrep-a'Linuxversion'
Downloadingsources
Downloadthesourceforthekernelyouwanttobuildusingtheappropriategitclonecommand:
$gitclonehttps://android.googlesource.com/kernel/common.git$gitclone https://android.googlesource.com/kernel/hikey-linaro$gitclone https://android.googlesource.com/kernel/x86_64.git$gitclone https://android.googlesource.com/kernel/exynos.git$gitclone https://android.googlesource.com/kernel/goldfish.git$gitclone https://android.googlesource.com/kernel/msm.git$gitclone https://android.googlesource.com/kernel/omap.git$gitclone https://android.googlesource.com/kernel/samsung.git$gitclone https://android.googlesource.com/kernel/tegra.git
The
goldfishprojectcontainsthekernelsourcesfortheemulatedplatforms.
The
msmprojecthasthesourcesforADP1,ADP2,NexusOne,Nexus4,Nexus5,Nexus6,Nexus5X,Nexus6P,Nexus7(2013),andcanbeusedasastarting
pointforworkonQualcommMSMchipsets.
The
omapprojectisusedforPandaBoardandGalaxyNexus,andcanbeusedasastartingpointforworkonTIOMAPchipsets.
The
samsungprojectisusedforNexusS,andcanbeusedasastartingpointforworkonSamsungHummingbirdchipsets.
The
tegraprojectisforXoom,Nexus7(2012),Nexus9,andcanbeusedasastartingpointforworkonNVIDIATegrachipsets.
The
exynosprojecthasthekernelsourcesforNexus10,andcanbeusedasastartingpointforworkonSamsungExynoschipsets.
The
x86_64projecthasthekernelsourcesforNexusPlayer,andcanbeusedasastartingpointforworkonIntelx86_64chipsets.
The
hikey-linaroprojectisusedforHiKeyreferenceboards,andcanbeusedasastartingpointforworkonHiSilicon620chipsets.
Downloadingaprebuiltgcc
Ensuretheprebuilttoolchainisinyourpath:$exportPATH=$(pwd)/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin:$PATH
or
$exportPATH=$(pwd)/prebuilts/gcc/darwin-x86/arm/arm-eabi-4.6/bin:$PATH
OnaLinuxhost,ifyoudon'thaveanAndroidsourcetree,youcandownloadtheprebuilttoolchainfrom:
$gitclone'target='_blank'>https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6[/code] Whenyouknowthelastcommitmessageforakernelandhavesuccessfullydownloadedthekernelsourceandprebuiltgcc,youarereadytobuildthekernel.Thefollowingbuildcommandsusethehikeykernel:
Buildingthekernel$exportARCH=arm64
$exportCROSS_COMPILE=aarch64-linux-android-
$cdhikey-linaro
$gitcheckout-bandroid-hikey-linaro-4.1origin/android-hikey-linaro-4.1
$makehikey_defconfig
$make
Tobuildadifferentkernel,simplyreplacehikey-linarowiththenameofthekernelyouwanttobuild.
Theimageoutputstothearch/arm64/boot/Imagedirectory;thekernelbinaryoutputstothearch/arm64/boot/dts/hisilicon/hi6220-hikey.dtbfle.
CopytheImagedirectoryandthehi6220-hikey.dtbfiletothehikey-kerneldirectory.
Alternatively,youcanincludetheTARGET_PREBUILT_KERNELvariablewhileusingmake bootimage(oranyothermakecommandlinethatbuildsabootimage).Thisvariableissupportedbyalldevicesasitissetupviadevice/common/populate-new-device.sh.
Forexample:$exportTARGET_PREBUILT_KERNEL=$your_kernel_path/arch/arm/boot/zImage-dtb
Note:Kernelnamesdifferbydevice.Tolocatethecorrectfilenameforyourkernel,refertodevice/<vendor>/<name>inthekernelsource.
KnownIssues
INTHISDOCUMENTBuildissues
Missing
CellBroadcastReceiverintorobuilds
Missing
CTSNativeXMLGenerator
BlackGingerbread
Emulator
Emulator
builtonMacOS10.7Liondoesn'twork.WITH_DEXPREOPT=trueand
emulatorbuilds.
"Permission
Denied"duringbuilds.
Build
errorsrelatedtousingthewrongcompiler.
Build
errorscausedbynon-defaulttoolsettings.
Build
errorwith4.0.xandearlieronMacOS10.7.
Build
erroronMacOSwithXCode4.3.
Build
errorwith4.0.xandearlieronUbuntu11.10.Sourcesyncissues
Difficulties
syncingthesourcecode(proxyissues).
Difficulties
syncingthesourcetree(VirtualBoxEthernetissues).
Difficulties
syncingthesourcetree(DNSissues).
Difficulties
syncingthesourcetree(TCPissues).Runtimeissues
Camera
andGPSdon'tworkonGalaxyNexus.
Evenwithourbestcare,smallproblemssometimesslipin.ThispagekeepstrackoftheknownissuesaroundusingtheAndroidsourcecode.
BuildissuesSymptom
MissingCellBroadcastReceiverintorobuilds
OnAOSPbuildsfortoro(uptoJellyBean4.2.1),CellBroadcastReceiverdoesn'tgetincludedinthesystem.
Cause:
There'satypoinvendor/samsung/toro/device-partial.mk,wherePRODUCT_PACKAGEShastheKreplacedbyanH.
Fix:Usethelatestpackagesfor4.2.2,ormanuallyfixthetypo.Symptom:OnsomebuildsofIceCreamSandwichandlater,thefollowingwarningisprintedearlyduringthebuild:
MissingCTSNativeXMLGenerator/bin/bash:line
0:cd:cts/tools/cts-native-xml-generator/src/res:Nosuchfileordirectory
Cause:Somemakefilereferencesthatpath,whichdoesn'texist.
Fix:None.Thisisaharmlesswarning.Symptom:Theemulatorbuiltdirectlyfromthegingerbreadbranchdoesn'tstartandstaysstuckonablackscreen.
BlackGingerbreadEmulator
Cause:ThegingerbreadbranchusesversionR7oftheemulator,whichdoesn'thaveallthefeaturesnecessarytorunrecentversionsofgingerbread.
Fix:UseversionR12oftheemulator,andanewerkernelthatmatchesthosetools.Noneedtodoacleanbuild.$repoforallplatform/external/qemu-cgitcheckoutaosp/tools_r12
$make
$emulator-kernelprebuilt/android-arm/kernel/kernel-qemu-armv7Symptom:Theemulator(anyversion)builtonMacOS10.7Lionand/oronXCode4.xdoesn'tstart.
EmulatorbuiltonMacOS10.7Liondoesn'twork.
Cause:Somechangeinthedevelopmentenvironmentcausestheemulatortobecompiledinawaythatpreventsitfromworking.
Fix:UseanemulatorbinaryfromtheSDK,whichisbuiltonMacOS10.6withXCode3andworksonMacOS10.7.Symptom:Whenconductingpartialbuildsorsyncs(makesystemnodependencies)onemulatorbuilds,theresultingbuilddoesn'twork.
WITH_DEXPREOPT=trueandemulatorbuilds.
Cause:AllemulatorbuildsnowrunDexoptimizationatbuildtimebydefault,whichrequirestofollowalldependenciestore-optimizetheapplicationseachtimetheframeworkchanges.
Fix:LocallydisableDexoptimizationswithexportWITH_DEXPREOPT=false,deletetheexistingoptimizedversionswithmake installcleanandrunafullbuildtore-generatenon-optimizedversions.Afterthat,partialbuildswillwork.Symptom:Allbuildsfailwith"PermissionDenied",possiblyalongwithanti-viruswarnings.
"PermissionDenied"duringbuilds.
Cause:Someanti-virusprogramsmistakenlyrecognizesomesourcefilesintheAndroidsourcetreeasiftheycontainedviruses.
Fix:Afterverifyingthattherearenoactualvirusesinvolved,disableanti-virusontheAndroidtree.Thishastheaddedbenefitofreducingbuildtimes.Symptom:Thebuildfailswithvarioussymptoms.Onesuchsymptomis
Builderrorsrelatedtousingthewrongcompiler.cc1:error:unrecognizedcommandlineoption"-m32"
Cause:TheAndroidbuildsystemusesthedefaultcompilerinthePATH,assumingit'sasuitablecompilertogeneratebinariesthatrunonthehost.Othersituations(e.g.usingtheAndroidNDKor
buildingthekernel)causethedefaultcompilertonotbeahostcompiler.
Fix:Usea"clean"shell,inwhichnopreviousactionscouldhaveswappedthedefaultcompiler.Symptom:Thebuildfailswithvarioussymptoms,possiblycomplainingaboutmissingfilesorfilesthathavethewrongformat.Onesuchsymptomis
Builderrorscausedbynon-defaulttoolsettings.member.
[...]inarchiveisnotanobject
Cause:TheAndroidbuildsystemtendstousemanyhosttoolsandtorelyontheirdefaultbehaviors.Somesettingschangethosetools'behaviorsandmakethembehaveinwaysthatconfusethebuild
system.VariablesknowntocausesuchissuesareCDPATHandGREP_OPTIONS.
Fix:BuildAndroidinanenvironmentthathasasfewcustomizationsaspossible.Symptom:BuildingIceCreamSandwich4.0.x(andolderversions)failsonMacOS10.7witherrorssimilartothis:
Builderrorwith4.0.xandearlieronMacOS10.7.Undefinedsymbols
forarchitecturei386:"_SDL_Init"
Cause:4.0.xisnotcompatiblewithMacOS10.7.
Fix:EitherdowngradetoMacOS10.6,orusethemasterbranch,whichcanbebuiltonMacOS10.7.$repoinit-bmaster
$reposyncSymptom:AllbuildsfailwhenusingXCode4.3.
BuilderroronMacOSwithXCode4.3.
Cause:XCode4.3switchedthedefaultcompilerfromgcctollvm,andllvmrejectscodethatusedtobeacceptedbygcc.
Fix:UseXCode4.2.Symptom:BuildingIceCreamSandwich4.0.x(andolderversions)onUbuntu11.10andnewerfailswitherrorssimilartothis:
Builderrorwith4.0.xandearlieronUbuntu11.10.<command-line>:0:0:
warning:"_FORTIFY_SOURCE"redefined[enabledbydefault]
Cause:Ubuntu11.10usesaversionofgccwherethatsymbolisdefinedbydefault,andAndroidalsodefinesthatsymbol,whichcausesaconflict.
Fix:EitherdowngradetoUbuntu10.04,orusethemasterbranch,whichcanbecompiledonUbuntu11.10andnewer.$repoinit-bmaster
$reposync
Sourcesyncissues
Symptom:
Difficultiessyncingthesourcecode(proxyissues).repoinitorreposyncfailwithhttp
errors,typically403or500.
Cause:Therearequiteafewpossiblecauses,mostoftenrelatedtohttpproxies,whichhavedifficultieshandlingthelargeamountsofdatagettingtransfered.
Fix:Whilethere'snogeneralsolution,usingpython2.7andexplicitlyusingreposync-j1havebeenreportedtoimprove
thesituationforsomeusers.Symptom:Whenrunning
Difficultiessyncingthesourcetree(VirtualBoxEthernetissues).reposyncinsomeVirtualBoxinstallations,theprocesshangsorfailswithavarietyofpossible
symptoms.OnesuchsymptomisDownloadError:HTTP500(InternalServerError:Servergotitselfintrouble).
Cause:ThedefaultnetworkbehaviorofVirtualBoxistouseNAT(NetworkAddressTranslation)toconnecttheguestsystemtothenetwork.Theheavynetworkactivityofreposynctriggerssomecorner
casesintheNATcode.
Fix:ConfigureVirtualBoxtousebridgednetworkinsteadofNAT.Symptom:Whenrunning
Difficultiessyncingthesourcetree(DNSissues).reposync,theprocessfailswithvariouserrorsrelatedtonotrecognizingthehostname.Onesuch
erroris<urlopenerror[Errno-2]Nameorservicenotknown>.
Cause:SomeDNSsystemshaveahardtimecopingwiththehighnumberofqueriesinvolvedinsyncingthesourcetree(therecanbeseveralhundredrequestsinaworst-casescenario).
Fix:Manuallyresolvetherelevanthostnames,andhard-codethoseresultslocally.
Youcanresolvethemwiththenslookupcommand,whichwillgiveyouonenumericalIPaddressforeachofthose(typicallyinthe"Address"
partoftheoutput).$nslookupgooglesource.com
$nslookupandroid.googlesource.com
Youcanthenhard-codethemlocallybyediting/etc/hosts,andaddingtwolinesinthatfile,oftheform:aaa.bbb.ccc.dddgooglesource.com
eee.fff.ggg.hhhandroid.googlesource.com
Notethatthiswillonlyworkaslongastheservers'addressesdon'tchange,andiftheydoandyoucan'tconnectyou'llhavetoresolvethosehostnamesagainandeditetc/hostsaccordingly.Symptom:
Difficultiessyncingthesourcetree(TCPissues).reposynchangswhilesyncing,oftenwhenit'scompleted99%ofthesync.
Cause:SomesettingsintheTCP/IPstackcausedifficultiesinsomenetworkenvironments,suchthatreposyncneithercompletes
norfails.
Fix:Onlinux,sysctl-wnet.ipv4.tcp_window_scaling=0.OnMacOS,disabletherfc1323extensioninthenetworksettings.
RuntimeissuesSymptom:CameraandGPSdon'tworkonGalaxyNexus.Asanexample,theCameraapplicationcrashesassoonasit'slaunched.
CameraandGPSdon'tworkonGalaxyNexus.
Cause:Thosehardwareperipheralsrequireproprietarylibrariesthataren'tavailableintheAndroidOpenSourceProject.
Fix:None.
相关文章推荐
- Android之FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
- android 数据库操作详解
- 五 Android Capabilities讲解
- H5与android原生的JS交互
- 在mac上加速android studio
- Android之FLAG_ACTIVITY_TASK_ON_HOME
- Android打包签名忘记密码,完美解决
- android 2.2 preview3 编译bug
- Android之Activity的四种启动模式
- android studio 初次配置
- Android Fragment完全解析
- Android 简单的验证码效果
- android源码解析之(二)-->异步消息机制
- Android实现点击AlertDialog上按钮时不关闭对话框
- Android_基于BMOB的聊天软件_添加好友
- 播放音乐,声音
- 安卓Serivice服务被系统杀掉的问题
- Android触摸事件与点击事件的区别
- android应用的数据应该保存到哪儿
- Android的Fragment