How many lines of code are in Android 14?

You probably came here because you searched for how much code on your device runs. The rough answer is 66 million for explanations why putting a number on this is misleading read the next section. If you want to explore explore the data yourself there are two more detailed sections below.

To be Android or not to be Android

If you want to be extremely liberal in your definition, you can consider android an ecosystem. That would include everything from the bootloader to developer documentation to store apps to the smartwatch that only works on android. This would be practically impossible to count and easily reach the billions. An extremely conservative approach would look at the bare minimum lines of OS code that need to be compiled to pass the official Compatibility Test Suite. While theoratically feasible and potentially useful the average user probably wouldn't recognize this as a mobile operating system.

As a middle ground this counting examines the contents of the main AOSP repo. A current checkout of the repo is roughly 168 GiB large this is however on only code but also documnetation, developer tools and other ecosystem components. To break down this code I created aosp-analyzer a set of scripts and a program that produces a handy HTML file (a slightly modified version is used for the interactive statistics at the end of this article). Let's break it down some more:

It depends on androids repo tool to obtain the source code and tokei to do the heavy line counting work. During line counting I do a preliminary categorization of line data based on the top level directories. After those first two slow steps it begins its actual analysis work: It seperates test code and documentation from the rest (1), removes data only files (mainly random test data) (2) and assembles the html (3). In case you are curious about the details, I think the code is more explicit than this text could ever be.

Quick facts

  • There are over 199 million source code lines contributing to android.
  • Roughly 66 million lines of code run on the average device.
  • 68 million lines of comments and documentation tell the developers what the code does.
  • 8.8% lines are empty.

Details

CodeCommentsBlank
Java35488211876125633057
Cpp3221947485173491753
CHeader1872257667868297198
AssemblyGAS6549211997713479
CppHeader3864091927577673
Kotlin3076699485047725
C2698066094843839
AsciiDoc188417458534479
Python942041216317095
Rust777821079610109
Protobuf611562435416021
Svg474547650
JavaScript4217843563583
Makefile1610369324054
Go1366619431915
Sh1055335402154
RPMSpecfile88923601163
Autoconf8483164302
LLVM5081142770
Meson4907609696
Html4232366467
TypeScript2968500170
CMake2881489580
Glsl2559636448
Bash2264720441
Automake194087412
Css1616119305
ModuleDef1218082
Ruby995256233
Batch73943263
Perl69826882
LinkerScript6922111
ReStructuredText5950245
ObjectiveC4507283
FlatBuffers335355114
ObjectiveCpp3317274
Prolog1312722
FSharp35010
MsBuild1800
Lua1504
DreamMaker000
Hex000
Happy000
D000
Dockerfile000
XSL000
DeviceTree000
Markdown0213986792
Text034008510720
CodeCommentsBlank
Java34720417009378460
TypeScript3081354913942
Bash2863652054168
Batch2103207717
Python1723218613351
Sh1575530662471
Kotlin1523780123359
Cpp933615801653
Rust5430451527
JavaScript41812321406
CHeader381726011556
Html3153200209
FreeMarker3104610614
Go280838322
Protobuf1149118213
Prolog7840121
Makefile386218129
Vue192062
Ruby183943
CMake1771523
Sass1646144
C1611825
Sql14014
Svg13311
Css1136027
Perl90112
Dockerfile6227
ModuleDef3124
AssemblyGAS12155
Text0197874572
Markdown0188606535
CodeCommentsBlank
Cpp1398426622235942191526
C1098915319560591800989
CHeader834341234745311667042
Rust3891385185339369972
Java37249381909706673631
Python2433186260352373893
CppHeader2409435448755416157
AssemblyGAS126425191378148896
Assembly5040431645945111
Protobuf497046538489193996
ReStructuredText4908500197535
Go2998967827634515
CMake2960123868832917
Autoconf2513014508040728
Kotlin2248356480636111
Sh2193176374237641
CSharp1907753955916865
VisualStudioProject18336551383
Perl1699392095920667
ObjectiveC1477392595926207
Html1468541331913624
JavaScript110164162909224
ModuleDef10167321036892
Makefile944642603324987
TypeScript790051925410603
ObjectiveCpp74436890113905
Glsl58324528413627
Svg3392316017
Css3046518865159
Meson3014423663615
Sql30004114902080
Happy2654203239
Tex25972126963177
Php24518217905741
Lua2338919942012
Automake2065429902954
Ruby2043272684035
DeviceTree1970322933037
Bash1692861583433
VisualStudioSolution15903038
OCaml1517427521625
Batch1479715683682
Pascal1234231252117
Swig108444621720
Dockerfile939445882739
Swift91282366987
FlatBuffers761236662136
FortranLegacy7163790733
Pan7122542692
D6540479375
Sass5790869770
RPMSpecfile5627129582
Alex37310764
ActionScript35672608746
MsBuild3502446235
XSL3371502364
VB63091651404
Dart2744411491
Hex24260133
R2332989585
OpenType2157289339
Ada2054457441
Velocity2037468525
Groovy17741715434
Hlsl170372287
PowerShell1545568291
Scons1473284354
Prolog11040156
LinkerScript10605780
Julia930473143
LLVM8661935
Elisp772516241
VimScript7709686
Processing7248932
Rakefile69681112
Lisp50281109
Tsx4579953
Arduino3893856
Pest2897283
Handlebars281027
Stratego223014
Nix185222
DotNetResource1741951
Gherkin1331432
CShell1292022
RubyHtml102025
XcodeConfig9520829
Jsonnet9310812
Zig73010
ABNF69123
FortranModern5604
Graphql5100
Fish421413
VBScript1203
AsciiDoc622
Zsh4262
Tcl400
Scala000
FSharp000
Text019146293186135
RON000
GDB000
Asn1000
Less000
Forth000
Fstar000
SpecmanE000
Jupyter000
Markdown0351987123491
CodeCommentsBlank
Rust33897341605349
Java33488713196960094
Go1593633661431461
Python1041131167415446
Kotlin46886184517649
Makefile29133114346029
Cpp1743342153508
Sh782629891602
CHeader624833191742
Perl6188602773
C41811145699
Protobuf339527421028
Css3221155599
JavaScript3009258246
TypeScript2421455217
Svg166197
Bash12881269414
AssemblyGAS1100255167
Html9793783
VisualStudioProject87600
Batch69984222
CSharp670183
CMake55211688
XSL3983442
CppHeader1596147
Elisp110318
VisualStudioSolution8202
Pan61511
Dockerfile3838
Autoconf300
DeviceTree000
Arduino000
Text0890346625
Assembly000
Glsl000
DreamMaker000
FSharp000
Markdown056661874
Cobol000
CodeCommentsBlank
Java2740222870461458470
Cpp50153010290290100
Kotlin1758775417326060
CHeader13142510068138990
Rust97602909514711
Python4061736037218
C1969346563523
Protobuf1298865544683
RPMSpecfile78090295
Sh38681314920
Bash2130227321
Makefile13593175444
Html125634120
DeviceTree441837
Batch3920133
Groovy3845464
Css36612023
AssemblyGAS33622088
Lua3111540
FlatBuffers2997255
CMake242745
CSharp179837
JavaScript1365025
LLVM106024
Prolog7009
Dockerfile60187
Glsl551913
CppHeader386819
LinkerScript1602
Autoconf1502
Markdown046321462
Text0580013437
SRecode000
Sql000
TypeScript000
Perl000
CodeCommentsBlank
Cpp1379756913394621728433
CHeader10171784346968174971
Java959124618048911764810
Python2896676304800501185
C2000847474412393535
Assembly18006546560316
Kotlin727274125977111043
LLVM698946503609161851
Html6932071196411267
Rust5651843145676542
Go5012803804350517
TypeScript340020942786402
Sh3116079215165214
AssemblyGAS20748010873561571
CppHeader1869791502623488
CSharp127862651111532
Autoconf11657926688793
Glsl72231571041
VisualStudioProject644895028
ObjectiveC610397195216871
Protobuf577952944213889
Groovy468522518812710
FortranLegacy386741555078
XSL380835639516031
ObjectiveCpp30503260148205
Perl2687277254754
Php26793113035253
CMake2567653894255
Ruby2549017564402
Hlsl24292201920
Makefile22202114758018
JavaScript2030227392830
Bash1448087923380
DeviceTree144313624764
ReStructuredText1383905497
Automake99828532208
Swift86003851119
Dart7574186938
DreamMaker692813421
Forth67095412
Dockerfile616144312194
Lua4861944949
AsciiDoc4146263802
Batch389996954
Css3761160633
Svg35845218
Meson3062478363
Sql29301130334
Velocity2630603783
OCaml2617551617
Prolog2157135185
FlatBuffers2035443471
D1885014
VisualStudioSolution1597010
Fstar141900
Scons1178278459
R1078553368
Cobol72500
Happy66303204
Hex64802
ModuleDef6332055
MsBuild6305863
Sass4959111
Ada354103162
LinkerScript209032
FSharp193049
OpenType176124
ActionScript1481046
Arduino132223
Pest1143929
Alex6401
Pan5668
FreeMarker51010
GDB446420
Rakefile36212
Scala294615
Elisp24164
RON2400
PowerShell2057
FortranModern182603
Tex16010
Tcl1166
Asn11004
SRecode400
Pascal100
SpecmanE100
Markdown06398922466
Text013618312369669
VBScript020
CodeCommentsBlank
Html10974672583388179733
ReStructuredText3626330100966
JavaScript44137961810039
Css4044335254623
Svg3783135293
Cpp2466542391577
AsciiDoc154385784479
Python1048251723203
C975863762632
Autoconf8825206128057
Tex711927341388
Java66349671077
XSL5752456397
Less553815331178
Sass5192204550
RPMSpecfile347521723
VisualStudioProject265800
Makefile2504344565
Php177918
Batch153015240
Perl1144406303
Sh1133320237
CMake869246134
Kotlin85814795
Automake693305208
Meson5993688
Velocity4033091
Bash33914394
Protobuf2323030
CHeader16044765
Rust93030
Go53117
Ruby353111
Lua420
Text010394920253
Markdown023434085049