Mobile/Fennec/Android/Eclipse: Difference between revisions

From MozillaWiki
< Mobile‎ | Fennec‎ | Android
Jump to navigation Jump to search
(Created page with "There is support for building Fennec using Eclipse in the tree. '''Building Fennec with Eclipse requires a custom Eclipse plugin'''. The preliminary Eclipse support landed i...")
 
(Redirect to renamed IDE page (not Eclipse))
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
There is support for building Fennec using Eclipse in the tree.
#REDIRECT [[Mobile/Fennec/Android/IDEs|IDEs]]
 
'''Building Fennec with Eclipse requires a custom Eclipse plugin'''.
 
The preliminary Eclipse support landed in {{bug|853045}}, and further enhancements are tracked at {{bug|924961}}.  {{bug|1029232}} landed the changes that require the custom Eclipse plugin.
 
= Quick start =
 
== Prerequisities ==
 
* [http://eclipse.org/ Eclipse] (Luna 4.4 is recommended; Kepler 4.2 should work as well)
* the most recent [https://developer.android.com/tools/sdk/eclipse-adt.html Eclipse ADT plugin]
 
You'll need a Mozilla source tree, like ''fx-team'' or ''mozilla-central'', and your mozconfig configured to build Fennec (see [Mobile/Fennec/Android#Setup_Fennec_mozconfig]).  You'll probably want to increase Eclipse's memory limits, as described in [http://stackoverflow.com/a/11093228 this stack overflow answer].  If you don't, you might hit GC issues because Android’s <code>dex</code> takes a good deal of memory.
 
== Install the custom plugin ==
 
Installing the plugin is easy.  The plugin is available to install from an Eclipse update site at http://people.mozilla.org/~nalexander/eclipse/update-site/.  In Eclipse, navigate to ''Help > Install New Software...''.  Add the update site with ''Name: fennec-eclipse'' and ''Location: http://people.mozilla.org/~nalexander/eclipse/update-site/''.  Select ''OK'', and you should see the ''Fennec Make Build Plugin''.  Check the box and click ''Next...'' to install it.  After you've installed, you may need to restart Eclipse.
 
== Prepare the Mozilla source tree ==
 
First, run
 
  mach build && mach package
 
That builds all the C/C++ libraries that Fennec needs, and installs them into the correct location.  Then, run
 
  mach build-backend -b=AndroidEclipse
 
That writes Eclipse project files and other support files needed to build in Eclipse.  Make a note of the path that <code>mach build-backend</code> outputs; that path contains the Eclipse project files, and you'll need it in a moment.
 
== Import the project files into Eclipse ==
 
In Eclipse, go to ''File > Import...'' and select ''General > Existing Projects into Workspace''. Enter the path printed by <code>mach build-backend</code>.  You should see many projects, including one named ''Fennec''.  We want that one, and all its dependencies; at the moment, that means
 
* Fennec
* FennecOmnijar
* FennecResources
* FennecResourcesBranding
* FennecResourcesGenerated
 
== Test your Eclipse configuration ==
 
You should be able to build in Eclipse now!  Try a clean build by selecting ''Project > Clean...''.  If all goes well, you will end up with no errors and a great deal of warnings.
 
Try to deploy an Eclipse-built Fennec to your device.  Right click the ''Fennec'' project, and select ''Run as... > Android Application''.  You should see messages about uploading APKs in the ''Android Console'' pane, and you should see Fennec start on your device.
 
= Frequently asked questions =
 
* I've run <code>mach build-backend -b=AndroidEclipse</code>.  Why do the Eclipse project directories look so empty?
 
The answer is [http://www.ncalexander.net/blog/2014/07/08/how-the-android-eclipse-integration-works/ complicated], but it's because some of things needed for a working Eclipse project require <code>mach build && mach package</code> to happen first, and (technically) a build backend happens ''before'' build and package time.  The Eclipse project directories are filled during the first Eclipse build (by the custom Eclipse plugin).
 
* I'm getting errors building with Eclipse.  What should I do?
 
Your first step is to go to ''Eclipse > Preferences... > Android > Build'' and set the ''Build output'' setting to ''Normal''.  That will show logging from the custom plugin and from the Eclipse Android integration that can help.
 
Your second step is to try refreshing all projects (Right click > ''Refresh'') and then doing a clean build (''Project > Clean build ...'').
 
* I clobbered and now my Eclipse projects are gone!
 
The Mozilla build system doesn't have much support for writing to a location that's not the object directory (yet!).  That means that when you clobber (delete the object directory entirely), the Eclipse projects get deleted.  That's okay, though: you can reconstitute them by re-running
 
  mach build-backend -b=AndroidEclipse
 
= The custom Eclipse plugin =
 
== What the plugin does ==
 
The plugin is conceptually simple: as the first step of the Eclipse build for each project, it executes a single shell command (if necessary).  Indeed, it replaces a custom ANT build invocation that did exactly the same work.  Some of the advantages of the plugin are
 
* error markers in the Eclipse ''Problems'' pane
* build output in the Eclipse ''Android Console''
* faster builds
* it is less likely to cause the build to loop forever.
 
== Source code ==
 
The source code for the plugin (and the related Eclipse feature and update site) is hosted at
https://github.com/ncalexan/fennec-eclipse.  Pull requests are always welcome!
 
= Additional resources =
 
There is a [http://www.ncalexander.net/blog/2014/06/24/better-fennec-builds-with-an-eclipse-plugin/ screencast getting started].  There is also a [http://www.ncalexander.net/blog/2014/03/24/eclipse-mini-tutorials/ series of video mini-tutorials].
 
There's a blog post discussing [http://www.ncalexander.net/blog/2014/07/08/how-the-android-eclipse-integration-works/ technical details of how the Eclipse build integration works].
 
= Support =
 
The first place to ask questions is #mobile on irc.mozilla.org.  Start there.
 
nalexander is the architect and implementer of most of the Eclipse integration.  rnewman, mcomella, and liuche all run, or have run, the integration as part of their daily development.  bnicholson contributed significantly to earlier versions of this work.
 
nalexander's [http://www.ncalexander.net/blog/ blog] is usually the first place to find tutorials, screencasts, and previews of new features.
 
= Developing with IntelliJ or Android Studio =
 
ckitching wrote a detailed, but now out-dated, [http://perplexedturnip.wordpress.com/2013/07/31/bludgeoning-intellij-idea-into-being-useful-for-mobile-firefox-development/ blog post explaining how to develop Fennec IntelliJ].  ckitching is working on supporting building with IntelliJ in the tree.

Latest revision as of 20:20, 5 December 2014