Changes

Jump to: navigation, search

Mobile/Fennec/Android

10,314 bytes removed, 18:38, 25 February 2016
Replace page content with mobile/fennec/android/overview. This is still a WIP – we should remove the old pages to avoid sharing out-dated info.
{{Admon/important|The Fennec build documentation has moved!|See the most up to date documentation at https://developer.mozilla.org/en-US/docs/Simple_Firefox_for_Android_build}}
== Building Fennec ==Here is a table of contents of all the in-depth information you might need to find about Firefox for Android development.
'''Right now it is possible New to build Fennec on most UNIX-like systems, including Mac OS X and many flavors of Linux.''' Most core developers run Mac OS X; a handful run Linux.the community? Welcome! [[Mobile/Get_Involved|Start here!]]
'''Sadly we do not yet support building Fennec on Microsoft Windows'''. We know of no strong reason that it should not be possible (now; in the past, it was not possible because Google did not release certain parts of the Android toolchain for Windows), but it's also not a priority. If you're interested in building on Windows, or can contribute, please CC yourself onto {{bug|1169873}}. === Getting the source =Develop ==*[[Mobile/Get Involved|New contributor page]]First, grab a clone of the **[[Mobile/Fennec source code repository. (If you don't have mercurial installed, install that, or you can run the setup script directly by following the instructions in the following section.)/Android/Suggested workflow|Suggested workflow]]  hg clone http*[https://hgdeveloper.mozilla.org/mozillaen-centralUSThe source files will be in the <tt>mozilla-central<docs/tt> directory, which we refer to as your ''source directory''.Simple_Firefox_for_Android_build Build documentation] Now run the setup script, which will walk you through the setup: .*[[Mobile/mach bootstrap Choose to build "Firefox for Android" at the prompts. This will help you install all the build prerequisites required for building Fennec on the most popular host operating systems (including OS X and Debian-flavoured Linuxes, including Ubuntu; but sadly not including Windows). You may need an hour or more to download and install dependencies (Java, the /Android SDK and NDK, and the Android platform itself, are very large). You may be prompted to enter your password or to accept license agreements./Testing|Testing]] NOTE: If that doesn't work, or you need more details: Follow the *[[https://wiki.mozilla.org/Mobile/Fennec/Android/Detailed_build_instructions detailed instructions CommonTips|Common tips & how-to set up a build environment] on your machine. Once you have done that, follow the steps to get the source, set up your mozconfig, and build Fennec. Before doing anything else, it's a good idea to set up Mercurial with reasonable defaults (patch defaults, etc). ]] .*[[Mobile/mach mercurial-setup ==== Alternative: Run the setup script directly ==== Run either of the following in a terminal. If you have curl installed (note that Mac OS X ships curl by default):  curl -O https:Fennec/Android/hg.mozilla.orgDevelopment/mozilla-central/raw-file/default/python/mozboot/bin/bootstrapAddons|Useful addons for development (e.py && python bootstrapg.pycopy profile)]] Or, if you have wget installed instead:  wget -q https:*[[Mobile/Fennec/Android/hgAdvancedTopics|Advanced topics (e.mozillag.org/mozilla-central/raw-file/default/python/mozboot/bin/bootstrap.py special build configs && python bootstrap.py Then go back and follow the directions as if you had launched the setup script by downloading the source. Once you have all the dependencies installed, you will need to clone the Firefox repository.advanced debugging)]]=== Preparing a Fennec mozconfig === Next, navigate to your source directory and create a text file called "mozconfig". The bootstrap script will print out the contents of mozconfig for you when it finishes (and you can run the script again to print this information out). It should be named <tt>mozconfig</tt> in your source directory, as the build scripts will read from the mozconfig file in your source directory by default, *[https://developergecko.mozillareadthedocs.org/en-US/docslatest/Configuring_Build_Options although you can configure this if you need to]. This is what a minimal mozconfig would look like:  # Build Firefox for Android: ac_add_options --enable-application=mobile/android ac_add_options --target=arm-linux-androideabi # With the following Android SDK and NDK: ac_add_options --with-android-sdk="/pathfennec/to/androidindex.html In-sdk" ac_add_options --with-android-ndk="/path/to/android-ndk-r10e" This assumes you have followed the instructions above and are using Android platform 22 and NDK version r10e. You must use <tt>$HOME</tt> instead of <tt>~</tt> in your mozconfig because <tt>~</tt> does not get expanded. Mozilla's build system writes all build intermediate files and output artifacts into a separate directory called the ''object directory''. The build system will choose a reasonable default name tree Firefox for the object directory if you don't specify one, but it's common to specify an object directory starting with "obj" and to put it inside your source directory. Add a line like the following to your mozconfig:  mk_add_options MOZ_OBJDIR=./objdir-droid === Building and deploying the Fennec Android package ===documentation] Before you start building, *[[http:Mobile//developer.android.com/guide/developing/device.html connect your Android device and enable USB debuggingTriage|Triage]]. The following steps will build Fennec (compile and link all C*[[Mobile/C++, Java, and JavaScript source code), prepare a fresh Fennec APK, and deploy Fennec to your Android device:  ./mach build ./mach package ./mach install During <tt>./mach build</tt> if you get an error that looks like this:   /path/to/mozilla-central/obj-x86_64-unknown-linux-gnu/Makefile Error 2 It means you're trying to build for Desktop, the reason might be that the build script can't see your mozconfig file. You can fix this by running <tt>|mach build|</tt> again after exporting Old splash page (a <tt>MOZCONFIG</tt> environment variable.  export MOZCONFIG=/path/to/mozilla-central/mozconfig ./mach buildlot of likely outdated material)]]
The APK file can be found in your <tt>objdir-droid=== Feature development ===*[[Mobile/dist<Fennec/tt> folder, and will be called something like <tt>fennec-28Android/Switchboard|Switchboard]]*[https://gecko.0a1readthedocs.org/en-US./latest/mobile/android-arm.apk</tt>. You can install this APK to your device manually using <tt>adb install<fennec/tt> or <tt>adjust.html Adjust]*[[Mobile/mach install</tt>.Distribution_Files|Distribution files]]
The name of the app that shows up on your phone will be "Fennec $USER" (where $USER is the username under which you built the code)=== General developer resources ===*[https://mozilla-version-control-tools.readthedocs.org/en/latest/hgmozilla/index.html Mercurial for Mozillians]*[https://mozilla-version-control-tools.readthedocs.org/en/latest/mozreview.html MozReview]
To speed up subsequent builds you should build only part of the <tt>mobile/android</tt> directory using <tt>./mach build mobile/android</tt> or <tt>./mach build mobile/android/base</tt>, depending on where your changes are== Metrics ==Discover how Firefox for Android is used through data.
==== Building faster with 'mach artifact' ====Since most Firefox for Android development is in Java and JS, you can speed up your build process by downloading rather than building the C++ code pieces, because that takes up the majority of build time. This is optional and not necessary for developing on Firefox for Android, so you can skip this section and do it later if you wish. ===== mach artifact setup =====Make sure that you have run <tt>mach mercurial-setup</tt> and installed the <tt>mozext</tt> tools when prompted. 1. Add the following to your mercurial config file <tt>.hg/hgrc</tt> in your source directory. [extensions] mozext = /PATH/TO/HOME/.mozbuild/version-control-tools/hgext/mozext 2. Mirror a local copy of the pushlog withNote: hg pushlogsyncMercurial should show a long (and slow) progress bar. From now on, each time you hg pull, you’ll also maintain your local copy of the pushlog. 3. Add the following lines to your mozconfig: ac_add_options --disable-compile-environment mk_add_options MOZ_OBJDIR=./objdir-frontend(The objdir can be whatever you choose, but it's named differently so you can go back to non-artifact building if you choose.) And that's all! For more detailed explanations of these steps, see [http://www.ncalexander.net/blog/2015/07/02/build-fennec-frontend-fast-with-mach-artifact/ nalexander's blog post] introducing mach artifact. ===== Building with mach artifact =====When building, you need to run an extra <tt>mach artifact</tt> step: ./mach build ./mach artifact install ./mach package ./mach install NOTE: This will not pick up C++ changes so if you are changing those files, you will have to use the original mozconfig method of building. === Developing Fennec with IDEs === Fennec has support for developing using IntelliJ (Ultimate and Community Edition) and Android Studio. (We also have some legacy support for Eclipse, but you should prefer using IntelliJ or Android Studio.) Get started [[/IDEs|Developing Fennec with IDEs]]. == Contributing Code ==Congratulations, now you've got a build set up! Now you can start contributing code. If you're a new contributor, you can pick a "good first bug" [http://www.joshmatthews.net/bugsahoy/?mobileandroid=1&unowned=1&simple=1 here], or jump into #mobile to ask. These [[Mobile/Fennec/Android/CommonTips|common Tips and How-To's]] will help you get started.  === Creating commits and submitting patches ===Mercurial (hg) is the the main version control system that Mozilla uses, and to submit code for review, you should be able to generate patches or commits. Be sure to run <tt>mach mercurial-setup</tt> when cloning the source code repository -- this will ensure you have good default settings and extensions. Instructions for submitting a patch can be found [https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/How_to_Submit_a_Patch#Committing_the_patch here]. If you have already applied for level 1 commit access, be sure to check out [http://mozilla-version-control-tools.readthedocs.org/en/latest/mozreview/install.html MozReview]. After writing the patch, make sure the commit message is of the correct format:<br />Bug <bug#> - <bug title>. r=<reviewer> So for example, for [https://bugzilla.mozilla.org/show_bug.cgi?id=1128431 bug 1128431], the commit message should be:<br />Bug 1128431 - 'Start browsing' link from onboarding v1.5 is not visible on small screen devices. r=liuche === Mercurial and Workflow ===Historically, Mozilla has used Mercurial patch queues to submit code changes for review. However, Mozilla developers metrics are now encouraged only available to use a Mercurial bookmark-based workflow. If you're a contributor and new to Mercurial, patch queues are conceptually simple employees and fine for getting your first few patches up; see the instructions on [https://developer.mozilla.org/enmay require sign-US/docs/Mercurial_Queues Mercurial patch queues]. If you're interested in using bookmarks, take a look at [http://mozilla-version-control-tools.readthedocs.org/en/latest/hgmozilla/bookmarks.html bookmarks-based development](If you want more information about bookmarks-based workflow, take a look at gps's *[https://peoplemetrics.mozillaservices.org/~gszorc/mastering-vcs/#1 slides]; [http://gregoryszorc.com/blog/category/mercurial/3/ gps's blog] is another good place to get information about version control at Mozilla.) For more information about configuring your hg environment to work well at Mozilla, see [http://mozilla-version-control-tools.readthedocs.org/en/latest/hgmozilla/index.html Mercurial for Mozillians]. Also, if you're curious to see an active hgrc with potentially useful aliases (and thus commonly used commands), check [https://github.com/mcomella/dotfiles/blob/master/hg/hgrc here]. === Additional topics ===For information on how to run and write tests, see the [[Mobile/Fennec/Android/Testing|Testing]] page. For more specialized topics, see these [[Mobile/Fennec/Android/AdvancedTopics|Advanced Topics]]. You can find information about advanced debugging, modifying build flags, etc. == Troubleshooting ==For if you're running into trouble building. === Android NDK and SDK version notes === The Fennec build system requires the following versions: * Android SDK Platform '''Android 6.0 (API 23)'''* SDK Build Tools '''23.0.1''' or later* SDK Platform Tools '''23.0.1''' or later* Android SDK Tools '''23.0.1''' or later* Android Support Repository '''21''' or later* Google Repository '''22''' or later If your build fails because you're missing one of the Android or Google requirements, your first step should be to run the <tt>mach bootstrap</tt>. If you don't want to run the bootstrapper, you can manually install by running the Android SDK manager: try <tt>mach android</tt>, or <tt>$ANDROID_SDK/tools/android</tt>. {{bug|1207680}} tracks listing these version requirements in one place in the source code. == Learn more ==*[[Mobile/Fennec/Android/CommonTips|Common Tips and Howfennec-To's]]*[[Mobiledashboard/Fennec/Android/Testing|Testing]]*[[Mobile/Distribution_Files|Distribution Files]Executive metrics]*[https://people.mozilla-version-control-tools.readthedocs.org/en/latest/hgmozilla/index.html Mercurial for Mozilla development]*[[Mobile~mfinkle/Fennecuitelemetry/Android/AdvancedTopics|Advanced Topics]UI telemetry]
Confirm
975
edits

Navigation menu