Skip to content

paul99/clank

Repository files navigation

Copyright (c) 2012 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.

This readme explains how to build and install your own Chromium apk using a
custom native library that you can build and modify as required.

Unfortunately, the app generated by following these steps using the current code
is likely to be unstable. This is a consequence of building over the Android
Open Source Project tree and we're working on it. Sorry for any inconveniences.


1. Build your custom libchromeview.so native library.
- First, you need to download the Android Open Source Project master branch.
  Follow the instructions in these pages:
  http://source.android.com/source/initializing.html
  http://source.android.com/source/downloading.html

- Inside the code create the folder 'external/chrome' and move there the
  contents of the tarball where this file was contained. The resulting folder
  structure should be as follows:

  Android Open Source Project Tree
    build: Android environment settings and others.
    external/chrome: where tarball contents should be moved to.
    external/chrome/apk: where the official apk will be extracted and modified.
                         Contains the tool change_chromium_package.py.
    external/chrome/out/Release: output folder. Will be created at the end of
                                 this step.

- Go back to the Android source root folder and run the following commands.
  These two commands will build Android and libchromeview respectively and
  can take quite a few minutes and many GB of free space. Make sure you meet the
  conditions described here: http://source.android.com/source/initializing.html

  . build/envsetup.sh && lunch full-eng && m -j16
  cd external/chrome && . build/android/envsetup.sh && clank_gyp && make -j16 libchromeview.so


2. Get the official Chrome.apk.
- Install Google Chrome from the Play store if not already in your device.
- Connect your device via USB. Make sure adb is available (see troubleshooting).
- Go to 'external/chrome/apk' and run:

  adb pull $(adb shell pm path com.android.chrome | sed 's/package:\([^\r ]\+\).*$/\1/g') Chrome.apk

  This will get the apk of the version installed in your device. Although you can
  probably get this file from the Internet it is recommended not to do so since
  you'll expose yourself to the possibility of fake apks with malicious code.


3. Unpack the apk contents.
- Although this could be done alone with the Android aapt tool it can be tricky
  to correctly unpack and repack the apk contents. For simplicity we suggest
  using apktool: http://code.google.com/p/android-apktool/

- If using apktool, in the 'external/chrome/apk' folder run:

  apktool d Chrome.apk

  Note that just unzipping the apk won't decode the resources and will make it
  hard to repack later.


4. Update the application package.
- Your apk should have a package name different to the official Chrome package.
  To correctly change it go to external/chrome/apk if not already there and run:

  ./change_chromium_package.py

  This will change the package name to "com.example.chromium" and the app name
  to "Example Chromium" by default. You can override these by running:

  ./change_chromium_package.py -u folder_were_the_apk_was_unpacked
                               -p desired_package_name
                               -a desired_app_name


5. Strip and replace libchromeview.so
- Once step 1 has finished you can find your native library ready in
  external/chrome/out/Release/lib.target/libchromeview.so

  This binary contains debug symbols that make its size greater than 1 GB.
  Remove the debug symbols by going to the folder above and running:

  arm-eabi-strip libchromeview.so

  This will reduce the size of libchromeview.so to the order of a few MB.

- Replace external/chrome/apk/Chrome/lib/armeabi-v7a/libchromeview.so with the
  file you compiled and stripped.


6. Repackage and install the new APK.
- First, repack our updated contents into a new apk by running:
  apktool b Chrome Chromium_unaligned.apk

- Sign the apk using jarsigner. Here's an example of how to do it using debug
  keys from the Android SDK, but feel free to use your own keys:

  jarsigner -sigalg MD5withRSA -digestalg SHA1
            -keystore PATH_TO_ANDROID_SDK/.android/debug.keystore
            -storepass android Chromium_unaligned.apk androiddebugkey

  You can find more information about signing apk files here:
  http://developer.android.com/tools/publishing/app-signing.html

- Align the package to 32 bits by running:
  zipalign -f -v 4 Chromium_unaligned.apk Chromium.apk

- Finally, install the application as usual: adb install -r Chromium.apk


Troubleshooting:
-> I get strange compile or link errors during step 1.
   Make sure you have set the environtment correctly and have enough free space
   and RAM to build and link Android. Double-check the instructions in:
   http://source.android.com/source/initializing.html

-> adb or some other commands mentioned here are not found.
   You're probably trying from an environment different from the one used to
   build android. From the Android source root folder run:

   . build/envsetup.sh && lunch full-eng

   Also make sure your android build succeeded. Alternatively you may find these
   tools in the Android SDK, but you'll still need a working Android build to
   compile your own libchromeview.so library.

About

This is a build of Chrome for Android for the MIPS architecture.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published