1 2 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 3 4 <html> 5 6 7 <head> 8 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 9 10 <base target="_top"> 11 12 <style type="text/css"> 13 14 15 /* default css */ 16 17 table { 18 font-size: 1em; 19 line-height: inherit; 20 } 21 22 23 tr { 24 25 text-align: left; 26 27 } 28 29 30 div, address, ol, ul, li, option, select { 31 margin-top: 0px; 32 margin-bottom: 0px; 33 } 34 35 p { 36 margin: 0px; 37 } 38 39 body { 40 margin: 6px; 41 padding: 0px; 42 font-family: Verdana, sans-serif; 43 font-size: 10pt; 44 background-color: #ffffff; 45 } 46 47 48 img { 49 -moz-force-broken-image-icon: 1; 50 } 51 52 @media screen { 53 html.pageview { 54 background-color: #f3f3f3 !important; 55 } 56 57 58 59 body { 60 min-height: 1100px; 61 62 counter-reset: __goog_page__; 63 } 64 * html body { 65 height: 1100px; 66 } 67 .pageview body { 68 border-top: 1px solid #ccc; 69 border-left: 1px solid #ccc; 70 border-right: 2px solid #bbb; 71 border-bottom: 2px solid #bbb; 72 width: 648px !important; 73 margin: 15px auto 25px; 74 padding: 40px 50px; 75 } 76 /* IE6 */ 77 * html { 78 overflow-y: scroll; 79 } 80 * html.pageview body { 81 overflow-x: auto; 82 } 83 /* Prevent repaint errors when scrolling in Safari. This "Star-7" css hack 84 targets Safari 3.1, but not WebKit nightlies and presumably Safari 4. 85 That's OK because this bug is fixed in WebKit nightlies/Safari 4 :-). */ 86 html*#wys_frame::before { 87 content: '\A0'; 88 position: fixed; 89 overflow: hidden; 90 width: 0; 91 height: 0; 92 top: 0; 93 left: 0; 94 } 95 96 97 98 99 .writely-callout-data { 100 display: none; 101 *display: inline-block; 102 *width: 0; 103 *height: 0; 104 *overflow: hidden; 105 } 106 .writely-footnote-marker { 107 background-image: url('MISSING'); 108 background-color: transparent; 109 background-repeat: no-repeat; 110 width: 7px; 111 overflow: hidden; 112 height: 16px; 113 vertical-align: top; 114 115 116 -moz-user-select: none; 117 } 118 .editor .writely-footnote-marker { 119 cursor: move; 120 } 121 .writely-footnote-marker-highlight { 122 background-position: -15px 0; 123 -moz-user-select: text; 124 } 125 .writely-footnote-hide-selection ::-moz-selection, .writely-footnote-hide-selection::-moz-selection { 126 background: transparent; 127 } 128 .writely-footnote-hide-selection ::selection, .writely-footnote-hide-selection::selection { 129 background: transparent; 130 } 131 .writely-footnote-hide-selection { 132 cursor: move; 133 } 134 135 136 .editor .writely-comment-yellow { 137 background-color: #FF9; 138 background-position: -240px 0; 139 } 140 .editor .writely-comment-yellow-hover { 141 background-color: #FF0; 142 background-position: -224px 0; 143 } 144 .editor .writely-comment-blue { 145 background-color: #C0D3FF; 146 background-position: -16px 0; 147 } 148 .editor .writely-comment-blue-hover { 149 background-color: #6292FE; 150 background-position: 0 0; 151 } 152 .editor .writely-comment-orange { 153 background-color: #FFDEAD; 154 background-position: -80px 0; 155 } 156 .editor .writely-comment-orange-hover { 157 background-color: #F90; 158 background-position: -64px 0; 159 } 160 .editor .writely-comment-green { 161 background-color: #99FBB3; 162 background-position: -48px 0; 163 } 164 .editor .writely-comment-green-hover { 165 background-color: #00F442; 166 background-position: -32px 0; 167 } 168 .editor .writely-comment-cyan { 169 background-color: #CFF; 170 background-position: -208px 0; 171 } 172 .editor .writely-comment-cyan-hover { 173 background-color: #0FF; 174 background-position: -192px 0; 175 } 176 .editor .writely-comment-purple { 177 background-color: #EBCCFF; 178 background-position: -144px 0; 179 } 180 .editor .writely-comment-purple-hover { 181 background-color: #90F; 182 background-position: -128px 0; 183 } 184 .editor .writely-comment-magenta { 185 background-color: #FCF; 186 background-position: -112px 0; 187 } 188 .editor .writely-comment-magenta-hover { 189 background-color: #F0F; 190 background-position: -96px 0; 191 } 192 .editor .writely-comment-red { 193 background-color: #FFCACA; 194 background-position: -176px 0; 195 } 196 .editor .writely-comment-red-hover { 197 background-color: #FF7A7A; 198 background-position: -160px 0; 199 } 200 201 .editor .writely-comment-marker { 202 background-image: url('MISSING'); 203 background-color: transparent; 204 padding-right: 11px; 205 background-repeat: no-repeat; 206 width: 16px; 207 height: 16px; 208 -moz-user-select: none; 209 } 210 211 .editor .writely-comment-hidden { 212 padding: 0; 213 background: none; 214 } 215 .editor .writely-comment-marker-hidden { 216 background: none; 217 padding: 0; 218 width: 0; 219 } 220 .editor .writely-comment-none { 221 opacity: .2; 222 filter:progid:DXImageTransform.Microsoft.Alpha(opacity=20); 223 -moz-opacity: .2; 224 } 225 .editor .writely-comment-none-hover { 226 opacity: .2; 227 filter:progid:DXImageTransform.Microsoft.Alpha(opacity=20); 228 -moz-opacity: .2; 229 } 230 231 232 233 234 .br_fix br:not(:-moz-last-node):not(:-moz-first-node) { 235 236 position:relative; 237 238 left: -1ex 239 240 } 241 242 .br_fix br+br { 243 position: static !important 244 } 245 } 246 247 h6 { font-size: 8pt } 248 h5 { font-size: 8pt } 249 h4 { font-size: 10pt } 250 h3 { font-size: 12pt } 251 h2 { font-size: 14pt } 252 h1 { font-size: 18pt } 253 254 blockquote {padding: 10px; border: 1px #DDD dashed } 255 256 a img {border: 0} 257 258 .pb { 259 border-width: 0; 260 page-break-after: always; 261 /* We don't want this to be resizeable, so enforce a width and height 262 using !important */ 263 height: 1px !important; 264 width: 100% !important; 265 } 266 267 .editor .pb { 268 border-top: 1px dashed #C0C0C0; 269 border-bottom: 1px dashed #C0C0C0; 270 } 271 272 div.google_header, div.google_footer { 273 position: relative; 274 margin-top: 1em; 275 margin-bottom: 1em; 276 } 277 278 279 /* Table of contents */ 280 .editor div.writely-toc { 281 background-color: #f3f3f3; 282 border: 1px solid #ccc; 283 } 284 .writely-toc > ol { 285 padding-left: 3em; 286 font-weight: bold; 287 } 288 ol.writely-toc-subheading { 289 padding-left: 1em; 290 font-weight: normal; 291 } 292 /* IE6 only */ 293 * html writely-toc ol { 294 list-style-position: inside; 295 } 296 .writely-toc-none { 297 list-style-type: none; 298 } 299 .writely-toc-decimal { 300 list-style-type: decimal; 301 } 302 .writely-toc-upper-alpha { 303 list-style-type: upper-alpha; 304 } 305 .writely-toc-lower-alpha { 306 list-style-type: lower-alpha; 307 } 308 .writely-toc-upper-roman { 309 list-style-type: upper-roman; 310 } 311 .writely-toc-lower-roman { 312 list-style-type: lower-roman; 313 } 314 .writely-toc-disc { 315 list-style-type: disc; 316 } 317 318 /* end default css */ 319 320 321 /* default print css */ 322 323 @media print { 324 body { 325 padding: 0; 326 margin: 0; 327 } 328 329 div.google_header, div.google_footer { 330 display: block; 331 min-height: 0; 332 border: none; 333 } 334 335 div.google_header { 336 flow: static(header); 337 } 338 339 /* used to insert page numbers */ 340 div.google_header::before, div.google_footer::before { 341 position: absolute; 342 top: 0; 343 } 344 345 div.google_footer { 346 flow: static(footer); 347 } 348 349 /* always consider this element at the start of the doc */ 350 div#google_footer { 351 flow: static(footer, start); 352 } 353 354 span.google_pagenumber { 355 content: counter(page); 356 } 357 358 span.google_pagecount { 359 content: counter(pages); 360 } 361 362 363 callout.google_footnote { 364 365 display: prince-footnote; 366 footnote-style-position: inside; 367 /* These styles keep the footnote from taking on the style of the text 368 surrounding the footnote marker. They can be overridden in the 369 document CSS. */ 370 color: #000; 371 font-family: Verdana; 372 font-size: 10.0pt; 373 font-weight: normal; 374 } 375 376 /* Table of contents */ 377 #WritelyTableOfContents a::after { 378 content: leader('.') target-counter(attr(href), page); 379 } 380 381 #WritelyTableOfContents a { 382 text-decoration: none; 383 color: black; 384 } 385 } 386 387 @page { 388 @top { 389 content: flow(header); 390 } 391 @bottom { 392 content: flow(footer); 393 } 394 @footnotes { 395 border-top: solid black thin; 396 padding-top: 8pt; 397 } 398 } 399 /* end default print css */ 400 401 402 /* custom css */ 403 404 405 /* end custom css */ 406 407 408 409 /* ui edited css */ 410 411 body { 412 font-family: Verdana; 413 414 font-size: 10.0pt; 415 line-height: normal; 416 background-color: #ffffff; 417 } 418 /* end ui edited css */ 419 420 421 422 /* editor CSS */ 423 .editor a:visited {color: #551A8B} 424 .editor table.zeroBorder {border: 1px dotted gray} 425 .editor table.zeroBorder td {border: 1px dotted gray} 426 .editor table.zeroBorder th {border: 1px dotted gray} 427 428 429 .editor div.google_header, .editor div.google_footer { 430 border: 2px #DDDDDD dashed; 431 position: static; 432 width: 100%; 433 min-height: 2em; 434 } 435 436 .editor .misspell {background-color: yellow} 437 438 .editor .writely-comment { 439 font-size: 9pt; 440 line-height: 1.4; 441 padding: 1px; 442 border: 1px dashed #C0C0C0 443 } 444 445 446 /* end editor CSS */ 447 448 </style> 449 450 </head> 451 452 <body onload="DoPageLoad();" 453 454 revision="cfnx2f69_111dp3jzfgb:107"> 455 456 457 458 459 <h1> 460 Using the Android Native Development Kit (NDK) 461 </h1> 462 version 1.3<br> 463 <br> 464 <h2> 465 Introduction 466 </h2> 467 The Android Native Development Kit enables developers to write shared libraries 468 in C or C++ and call them from Java code. The native shared libraries can be 469 packaged into apk files along with a normal Android application written in Java, 470 so that the resulting Android application can be downloaded and installed on an 471 Android phone.<br> 472 <br> 473 The Native Development Kit consists of:<br> 474 <ul> 475 <li> 476 C/C++ headers for native APIs<br> 477 </li> 478 <li> 479 C/C++ libraries for native APIs<br> 480 </li> 481 <li> 482 Documentation 483 </li> 484 <li> 485 Sample Code 486 </li> 487 </ul> 488 <br> 489 The Native Development Kit is designed to be used with the Android SDK:<br> 490 <ul> 491 <li> 492 The NDK is used to create a shared library containing native code. 493 </li> 494 <li> 495 The SDK is used to create an Android application written in Java that calls 496 into the native code shared library. 497 </li> 498 </ul> 499 <h1> 500 </h1> 501 <h2> 502 Setting up your machine<br> 503 </h2> 504 The Native Development Kit may be installed on either Linux or OS X. Developing 505 under Windows is not yet supported.<br> 506 <div> 507 <h3> 508 Linux Installation 509 </h3> 510 The 511 Android build is routinely tested on recent versions of Ubuntu (6.06 and later), but 512 may work on other distributions as well.<br> 513 <h4> 514 <a name=TOC-Ubuntu-Linux-i386-></a><span style=FONT-FAMILY:Verdana>Ubuntu 515 Linux (i386)</span> 516 </h4> 517 <div style=FONT-FAMILY:Verdana> 518 To set up your Linux development environment, make sure you have the 519 following:<span style="WORD-SPACING:0px; FONT-STYLE:normal; FONT-VARIANT:normal; FONT-WEIGHT:normal; font-size-adjust:none; font-stretch:normal; TEXT-TRANSFORM:none; COLOR:#000000; WHITE-SPACE:normal; LETTER-SPACING:normal; border-collapse:separate"><font size=2> 520 </font></span> 521 </div> 522 <div style="MARGIN-TOP:0px; MARGIN-BOTTOM:0px; FONT-FAMILY:Verdana"> 523 <div style="MARGIN-TOP:0px; MARGIN-BOTTOM:0px"> 524 <div style="MARGIN-TOP:0px; MARGIN-BOTTOM:0px"> 525 <ul style="MARGIN-TOP:0px; MARGIN-BOTTOM:0px"> 526 <li style="MARGIN-TOP:8px; MARGIN-BOTTOM:8px"> 527 Git 1.5.4 or 528 newer<span style="FONT-WEIGHT:normal; WORD-SPACING:0px; TEXT-TRANSFORM:none; COLOR:#000000; FONT-STYLE:normal; WHITE-SPACE:normal; LETTER-SPACING:normal; border-collapse:separate; FONT-VARIANT:normal"><font size=2>. </font></span> 529 </li> 530 </ul> 531 </div> 532 </div> 533 </div> 534 <blockquote style="BORDER:medium none ; MARGIN:0pt 0pt 0pt 40px; PADDING:0px"> 535 <span style=FONT-FAMILY:arial><span style="FONT-WEIGHT:normal; WORD-SPACING:0px; TEXT-TRANSFORM:none; COLOR:#000000; FONT-STYLE:normal; WHITE-SPACE:normal; LETTER-SPACING:normal; border-collapse:separate; FONT-VARIANT:normal"><span style="FONT-FAMILY:courier new,monospace">$ 536 </span></span><span style="FONT-FAMILY:courier new,monospace">sudo apt-get 537 install git-core<br> 538 </span></span> 539 </blockquote> 540 <div> 541 <div style="MARGIN-TOP:0px; MARGIN-BOTTOM:0px"> 542 <div style="MARGIN-TOP:0px; MARGIN-BOTTOM:0px; FONT-FAMILY:arial,sans-serif"> 543 <div style="MARGIN-TOP:0px; MARGIN-BOTTOM:0px"> 544 <h4> 545 <a name=TOC-Ubuntu-Linux-amd64-></a><span style=FONT-FAMILY:Verdana>Ubuntu 546 Linux (amd64)</span> 547 </h4> 548 <span style=FONT-FAMILY:Verdana>This has not been as well 549 tested.</span> 550 </div> 551 <div style="MARGIN-TOP:0px; MARGIN-BOTTOM:0px; FONT-FAMILY:Verdana"> 552 <br> 553 </div> 554 <div style="MARGIN-TOP:0px; MARGIN-BOTTOM:0px; FONT-FAMILY:Verdana"> 555 The Android build requires a 32-bit build environment: 556 </div> 557 <div style="MARGIN-TOP:0px; MARGIN-BOTTOM:0px; FONT-FAMILY:Verdana"> 558 <ul> 559 <li> 560 Get the packages as listed above in the i386 561 instructions:<span style="FONT-WEIGHT:normal; WORD-SPACING:0px; TEXT-TRANSFORM:none; COLOR:#000000; FONT-STYLE:normal; WHITE-SPACE:normal; LETTER-SPACING:normal; border-collapse:separate; FONT-VARIANT:normal"> </span> 562 </li> 563 </ul> 564 </div> 565 </div> 566 </div> 567 </div> 568 <blockquote style="BORDER:medium none ; MARGIN:0pt 0pt 0pt 40px; PADDING:0px"> 569 <span style=FONT-FAMILY:arial><span style="FONT-WEIGHT:normal; WORD-SPACING:0px; TEXT-TRANSFORM:none; COLOR:#000000; FONT-STYLE:normal; WHITE-SPACE:normal; LETTER-SPACING:normal; border-collapse:separate; FONT-VARIANT:normal"><span style="FONT-FAMILY:courier new,monospace">$ </span></span><span style="FONT-FAMILY:courier new,monospace">sudo 570 apt-get install git-core<br> 571 </span></span> 572 </blockquote> 573 <h4> 574 <a name=TOC-Other-Linux></a>Other Linux 575 </h4> 576 <p> 577 There's 578 no reason why Android cannot be built on non-Ubuntu systems<span style=FONT-WEIGHT:normal><font size=2>. In general you will need:</font></span> 579 </p> 580 <ul> 581 <li> 582 Git 1.5.4 or newer. You can find it at <a href=http://git.or.cz/ rel=nofollow>http://git.or.cz/</a><span style=FONT-FAMILY:arial></span> 583 </li> 584 </ul> 585 <div> 586 <h3> 587 Mac OS Installation 588 </h3> 589 <ul> 590 <li> 591 <span style=FONT-FAMILY:arial,sans-serif>To build the Android files in a 592 Mac OS environment, you need an Intel/x86 machine. The Android build 593 system and tools do not support the older PowerPC architecture.</span> 594 </li> 595 <li> 596 <span style=FONT-FAMILY:arial,sans-serif>Android must be built on a 597 case-sensitive file system.<br> 598 </span> 599 </li> 600 <ul> 601 <li> 602 We recommend that you build Android on a partition that has been 603 formatted with the "Case-sensitive Journaled HFS+" file system: 604 </li> 605 <ul> 606 <li> 607 A case-sensitive file system is required because the sources contain 608 files that differ only in case. 609 </li> 610 <li> 611 Journaled systems are more robust. (This is optional, but 612 recommended.) 613 </li> 614 <li> 615 HFS+ is required to successfully build Mac OS applications such as 616 the Android Emulator for OS X. 617 </li> 618 </ul> 619 <li> 620 If you want to avoid partitioning/formatting your hard drive, you can 621 use a case-sensitive disk image instead. 622 </li> 623 <ul> 624 <li> 625 To create the image:<br> 626 <ul> 627 <li> 628 launch /Applications/Utilities/Disk Utility 629 </li> 630 <li> 631 select "New Image" 632 </li> 633 <li> 634 size: 8 GB (this will work, but you can choose more if you want 635 to) 636 </li> 637 <li> 638 volume format: case sensitive, journaled 639 </li> 640 </ul> 641 </li> 642 <li> 643 This will create a .dmg file which, once mounted, acts as a drive 644 with the required formatting for Android development. For a disk 645 image named "android.dmg" stored in your home directory, you can add 646 the following to your ~/.bash_profile to mount the image when you 647 execute "mountAndroid":<br> 648 <br> 649 <div style=MARGIN-LEFT:40px> 650 <span style="FONT-FAMILY:courier new,monospace"># command to mount 651 the android file 652 image</span><br style="FONT-FAMILY:courier new,monospace"> 653 <span style="FONT-FAMILY:courier new,monospace">function 654 mountAndroid { hdiutil attach ~/android.dmg 655 -mountpoint /Volumes/android; }</span><br> 656 </div> 657 <br> 658 Once mounted, you'll do all your work in the "android" volume. You 659 can eject it (unmount it) just like you would with an external 660 drive. 661 </li> 662 </ul> 663 </ul> 664 </ul> 665 <div> 666 <br> 667 <ul> 668 <li> 669 Install git 1.5.4 or newer. You can find it at 670 <a href=http://git.or.cz/ rel=nofollow>http://git.or.cz/</a> 671 </li> 672 </ul> 673 <h2> 674 Installing the Android SDK 675 </h2> 676 The Android NDK uses the Android SDK. You can find the Android SDK at 677 <a href=http://code.google.com/android/download.html id=a.-o title=http://code.google.com/android/download.html>http://code.google.com/android/download.html</a><br> 678 This version of the Android NDK requires the Cupcake version of the 679 Android SDK.<br> 680 <br> 681 <h2> 682 Installing the Prebuilt Native Toolchain<br> 683 </h2> 684 The NDK uses the prebuilt native toolchain from the Android Open Source 685 git repository.<br> 686 <br> 687 To download the prebuilt native toolchain to your working directory, 688 execute the following commands:<br> 689 <br> 690 <span style="FONT-FAMILY:Courier New"></span> 691 <div style=MARGIN-LEFT:40px> 692 <span style="FONT-FAMILY:Courier New">git clone 693 git://android.git.kernel.org/platform/prebuilt.git</span><br> 694 <span style="FONT-FAMILY:Courier New">cd prebuilt</span><br> 695 <span style="FONT-FAMILY:Courier New">git checkout -b cupcake -t 696 origin/cupcake</span><br> 697 </div> 698 <div style=MARGIN-LEFT:40px> 699 <span style="FONT-FAMILY:Courier New"></span> 700 </div> 701 <br> 702 <h2> 703 Setting Environment Variables 704 </h2> 705 The NDK requires that you set two environment variables:<br> 706 <ul> 707 <li> 708 PREBUILT must be set to the directory that contains the prebuilt 709 toolchain. Include the "prebuilt" directory in the path. Example: 710 /Volumes/android/prebuilt<br> 711 </li> 712 <li> 713 ANDROID_SDK_BASE must be set to the directory that contains the 714 Android SDK. Example: ~/AndroidSDK<br> 715 </li> 716 </ul> 717 <br> 718 <h2> 719 <span style=FONT-FAMILY:Verdana>Unpacking the NDK</span> 720 </h2> 721 Unpack the android_pndk.tar.gz into your working directory<br> 722 <br> 723 <div style=MARGIN-LEFT:40px> 724 <span style="FONT-FAMILY:Courier New">tar -zxvf 725 android_pndk.tar.gz</span><br> 726 </div> 727 <br> 728 This will create a directory called pndk. It should contain a README.html 729 file (this file) and the following directories: config, include, lib, and 730 sample.<br> 731 <br> 732 Look in the "samples" directory for samples showing how to use the NDK.<br> 733 <br> 734 <br> 735 </div> 736 <br> 737 </div> 738 <br> 739 </div> 740 <br></body> 741 </html>