Skip to content

Android Development

jab edited this page Aug 18, 2016 · 20 revisions

uProxy can now be built as an Android app using the Cordova Chrome Apps (CCA) tool, a.k.a. Chrome Apps for Mobile Toolchain.

Environment Setup

After building uProxy for desktop:

  1. If on OS X, make sure you have Xcode 6.4 installed. Xcode 7 will not work.
  2. Install the Android SDK.
    • Linux: Since the command-line tools are largely unmaintained, the easiest way to get them is as part of Android Studio. Download the installer and start Android Studio; on first run, it will prompt you to install an SDK.
    • OS X: brew install android-sdk
  3. Set your ANDROID_HOME environment variable to the Android SDK path, e.g. run export ANDROID_HOME=$HOME/Android/Sdk and add it to your .bashrc (/usr/local/opt/android-sdk on OS X).
  4. Install adb.
    • Linux: adb is available through your package manager. For example, on Ubuntu run apt-get install android-tools-adb.
    • OS X: adb should have been installed by the brew install android-sdk step already. Make sure with which adb.
  5. Confirm that your cca package is ready by running node_modules/.bin/cca checkenv from your git clone root directory.
  6. Install the Android NDK (brew install android-ndk on OS X).
  7. Confirm that ndk-build is in your PATH with which ndk-build.
  8. Run the Android SDK Manager (e.g. invoke android at the command line) and ensure that "SDK Platform" is installed for Android 6.0 (API 23). If you ended up with "SDK Platform" installed for Android 7.0 (API 24) only, you'll still need to install the 6.0/API 23 SDK Platform.

Now, you can build the app using grunt build_android. The output, a file ending in .apk, will appear in build/src/android/platforms/android/build/outputs/apk/. Depending on the build configuration, the file might be named android-debug.apk, android-armv7-debug.apk, etc..

Installing on an Android device

  • To install the app, first Enable USB Debugging on your test phone, then connect it to your computer and accept the connection on the phone.
  • Then, on your computer, install the app on the phone using a command like adb install -r build/src/android/platforms/android/build/outputs/apk/android-armv7-debug-unaligned.apk. Make sure you don't have uProxy installed on the device already, or you'll get Failure [INSTALL_FAILED_UPDATE_INCOMPATIBLE].
  • You may then launch the app from the phone. Rerunning this command should close the app and replace it with a new version, but will not overwrite saved state on the device.

If you encounter an error or want to complete delete uProxy from your phone, you can do so via Settings -> Apps -> uProxy, which as a button labeled "Uninstall for all users".

Installing on an Android emulator

  • Create a virtual device using the Android Virtual Device Manager with an API of 23 (Marshmallow) or higher. Choosing the same architecture as your host system for the CPU/ABI (e.g. x86_64) will result in faster emulation, but obfuscation will fail silently, and in one recent case uProxy wouldn't even start, so you may have to choose ARM and suffer with 10x slower emulation.
  • Launch the emulator and check adb devices at the command line to make sure an emulator is running.
  • Install the app from the command line with e.g. adb install -r build/src/android/platforms/android/build/outputs/apk/android-armv7-debug.apk. You should see success if the app is installed.
  • You may then launch the app from the emulator.

Debugging

You can remotely debug the uProxy instance running on your Android device using the Chrome Developer Tools on your desktop Chrome. Just go to chrome://inspect in Chrome, and click the "inspect" link corresponding to the uProxy app on your connected Android device:

screenshot

screenshot

Creating a Play Store release build

Android app release builds must be signed. To create a release build:

  1. Get the appropriate play_store_keys.p12 and android-release-keys.properties files, and symlink them into a keys directory in the git repo root.
  • The uProxy team's release keys are stored in a secure location, not in the public git repository. Symlinking ensures that you do not accidentally copy the keys into insecure storage.
  1. Run grunt release_android
  2. From the build/dev/uproxy/android/platforms/android/build/outputs/apk/ directory, upload android-release.apk, android-x86-release.apk, and android-armv7-release.apk to the Play Store using the multiple APK upload procedure.
  • This allows us to have a smaller build (~10 MB) for modern Android, and a larger build (~33 MB) for older Android versions that need Crosswalk because the system webview is too old to run uProxy.

Clone this wiki locally