{"id":358,"date":"2014-10-11T02:46:38","date_gmt":"2014-10-11T00:46:38","guid":{"rendered":"http:\/\/blogs.igalia.com\/eocanha\/?p=358"},"modified":"2014-10-11T02:46:38","modified_gmt":"2014-10-11T00:46:38","slug":"hacking-on-chromium-for-android-from-eclipse-part-1","status":"publish","type":"post","link":"https:\/\/eocanha.org\/blog\/2014\/10\/11\/hacking-on-chromium-for-android-from-eclipse-part-1\/","title":{"rendered":"Hacking on Chromium for Android from Eclipse (part 1)"},"content":{"rendered":"<p>In the <a href=\"http:\/\/www.chromium.org\/developers\">Chromium Developers<\/a> website has some excellent resources on how to setup an environment to build Chromium for <a href=\"http:\/\/code.google.com\/p\/chromium\/wiki\/LinuxBuildInstructions\">Linux desktop<\/a> and <a href=\"http:\/\/code.google.com\/p\/chromium\/wiki\/AndroidBuildInstructions\">for Android<\/a>. There&#8217;s also a detailed guide on <a href=\"https:\/\/code.google.com\/p\/chromium\/wiki\/LinuxEclipseDev\">how to setup Eclipse as your development environment<\/a>, enabling you to take advantage of code indexing and enjoy features such as type hierarchy, call hierarchy, macro expansion, references and a lot of tools much better than the poor man&#8217;s trick of grepping the code.<\/p>\n<p>Unfortunately, there are some integration aspects not covered by those guides, so joining all the dots is not a smooth task. In this series of posts, I&#8217;m going to explain the missing parts to setup a working environment to code and debug Chromium for Android from Eclipse, both C++ and Java code. All the steps and commands from this series of posts have been tested in an Ubuntu Saucy chroot. See my previous post on <a href=\"http:\/\/blogs.igalia.com\/eocanha\/2013\/12\/19\/using-schroot-to-have-a-stable-and-transplantable-development-environment\/\">how to setup a chroot<\/a> if you want to know how to do this.<\/p>\n<p><strong>Get the source code<\/strong><\/p>\n<p>See the <a href=\"http:\/\/dev.chromium.org\/developers\/how-tos\/get-the-code\">get-the-code<\/a> guide.\u00a0Don&#8217;t try to reconvert a normal Desktop build into an Android build. It just doesn&#8217;t work. The detailed s<span style=\"line-height: 1.5em\">teps to get the code from scratch and prepare the dependencies are the following:<\/span><\/p>\n<pre> cd ANDROID # Or the directory you want\n fetch --nohooks android --nosvn=True\n cd src\n git checkout master\n build\/install-build-deps.sh\n build\/install-build-deps-android.sh\n gclient sync --nohooks<\/pre>\n<p>Configure and generate the project (see <a href=\"http:\/\/code.google.com\/p\/chromium\/wiki\/AndroidBuildInstructions\">AndroidBuildInstructions<\/a>), from src:<\/p>\n<pre> # Make sure that ANDROID\/.gclient has this line:\n # target_os = [u'android']\n # And ANDROID\/chromium.gyp_env has this line:\n # { 'GYP_DEFINES': 'OS=android', }\n gclient runhooks<\/pre>\n<p>Build Chrome shell, from src:<\/p>\n<pre> # This builds\n ninja -C out\/Release chrome_shell_apk\n # This installs in the device\n # Remember the usual stuff to use a new device with adb:\n # http:\/\/developer.android.com\/tools\/device.html \n # http:\/\/developer.android.com\/tools\/help\/adb.html#Enabling\n # Ensure that you can adb shell into the device\n build\/android\/adb_install_apk.py --apk ChromeShell.apk --release<\/pre>\n<p>If you ever need to update the source code, follow this recipe and use Release or Debug at your convenience:<\/p>\n<pre> git pull origin master\n gclient sync\n # ninja -C out\/Release chrome_shell_apk\n ninja -C out\/Debug chrome_shell_apk\n # build\/android\/adb_install_apk.py --apk ChromeShell.apk --release\n build\/android\/adb_install_apk.py --apk ChromeShell.apk --debug<\/pre>\n<p>As a curiosity, it&#8217;s worth to mention that <strong>adb<\/strong> is installed on third_party\/android_tools\/sdk\/platform-tools\/adb.<\/p>\n<p><strong>Configure Eclipse<\/strong><\/p>\n<p>To configure Eclipse, follow the instructions in <a href=\"https:\/\/code.google.com\/p\/chromium\/wiki\/LinuxEclipseDev\">LinuxEclipseDev<\/a>. They work nice with Eclipse Kepler.<\/p>\n<p>In order to open and debug the Java code properly, it&#8217;s also interesting to <a href=\"http:\/\/developer.android.com\/sdk\/installing\/installing-adt.html\">install the ADT plugin in Eclipse <\/a>too.\u00a0Don&#8217;t try to reuse the Android SDK in &#8220;third_party\/android_tools\/sdk&#8221;. It seems to lack some things. Download a <a href=\"http:\/\/developer.android.com\/sdk\/index.html#download\">fresh standalone SDK from the official page<\/a>\u00a0instead and tell the ADT plugin to use it.<\/p>\n<p>In the next post, I will explain how to debug C++ code running in the device, both from the command line and from Eclipse.<\/p>\n<p><a href=\"\/blog\/wp-content\/uploads\/2014\/10\/chromium_android_eclipse_cpp1.png\"><img loading=\"lazy\" class=\"alignnone size-medium wp-image-379\" alt=\"chromium_android_eclipse_cpp\" src=\"\/blog\/wp-content\/uploads\/2014\/10\/chromium_android_eclipse_cpp1-300x162.png\" width=\"300\" height=\"162\" srcset=\"https:\/\/eocanha.org\/blog\/wp-content\/uploads\/2014\/10\/chromium_android_eclipse_cpp1-300x162.png 300w, https:\/\/eocanha.org\/blog\/wp-content\/uploads\/2014\/10\/chromium_android_eclipse_cpp1-1024x554.png 1024w, https:\/\/eocanha.org\/blog\/wp-content\/uploads\/2014\/10\/chromium_android_eclipse_cpp1.png 1600w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the Chromium Developers website has some excellent resources on how to setup an environment to build Chromium for Linux desktop and for Android. There&#8217;s also a detailed guide on how to setup Eclipse as your development environment, enabling you to take advantage of code indexing and enjoy features such as type hierarchy, call hierarchy, &hellip; <a href=\"https:\/\/eocanha.org\/blog\/2014\/10\/11\/hacking-on-chromium-for-android-from-eclipse-part-1\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Hacking on Chromium for Android from Eclipse (part 1)<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[8,9,2,7],"tags":[],"_links":{"self":[{"href":"https:\/\/eocanha.org\/blog\/wp-json\/wp\/v2\/posts\/358"}],"collection":[{"href":"https:\/\/eocanha.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/eocanha.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/eocanha.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/eocanha.org\/blog\/wp-json\/wp\/v2\/comments?post=358"}],"version-history":[{"count":0,"href":"https:\/\/eocanha.org\/blog\/wp-json\/wp\/v2\/posts\/358\/revisions"}],"wp:attachment":[{"href":"https:\/\/eocanha.org\/blog\/wp-json\/wp\/v2\/media?parent=358"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/eocanha.org\/blog\/wp-json\/wp\/v2\/categories?post=358"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/eocanha.org\/blog\/wp-json\/wp\/v2\/tags?post=358"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}