Skip to content

Android

alex [dot] kramer [at] g_m_a_i_l [dot] com edited this page Sep 18, 2018 · 16 revisions

Proxy through Charles

UI Automator Viewer

~/Library/Android/sdk/tools/bin/uiautomatorviewer

Configure Charles

  1. Open Proxy > Proxy Settings
  2. Leave the port as default (8888) and select “Enable transparent HTTP Proxying”
  3. Open Proxy > SSL Proxy Settings
  4. Select “Enable SSL Proxying”
  5. Add a new entry * in "Locations"

Configure emulator

Via command line:

emulator -netdelay none -netspeed full -avd [EMULATOR NAME] -http-proxy [LOCAL IP]]:[PORT]
  • EMULATOR NAME: List of emulators in ~/.android/avd/ e.g. Nexus_5X_API_25
  • LOCAL IP: IP of machine where Charles is running
  • PORT: Default Charles port (should be 8888)

Via emulator:

  1. Open Settings > Wireless & networks > ... More > Cellular networks > Access Point Names > T-Mobile US
  2. Change Proxy to local IP where Charles is running
  3. Change Port to Charles default (should be 8888)

Install SSL cert

  1. Visit http://charlesproxy.com/getssl in the emulator browser

Declare Proguard rules for library

android {
    ...
    defaultConfig {
        ...
        consumerProguardFiles 'proguard-rules.pro'
    }
}

Manually build

./gradlew clean assembleDebug

Manually install apk

  • ~/Library/Android/sdk/platform-tools/adb
  • adb install [path to .apk]

Manually launch emulator

  • ~/Library/Android/sdk/tools/emulator -avd Nexus_6_API_23 -netspeed full -netdelay none -http-proxy http://127.0.0.1:8888 -port 5554

Push to JCenter

Setup

Create local.properties at top level:

sdk.dir=/Users/alex/Library/Android/sdk
bintray.user=username
bintray.apikey=apikey
bintray.gpg.password=password

JCenter repo: https://bintray.com/[user]/maven/[repo name]

Push:

Test:

Install the new version of the library from JCenter in a new app and test that Gradle can sync and that everything works.

  • Make sure the JCenter repo is configured in the new project's build.gradle:
allprojects {
    repositories {
        ...
        maven {
            ...
            url 'https://dl.bintray.com/[username]/maven/'
        }
    }
}
  • Make sure the package is configured in the new project's app/build.gradle:
dependencies {
    ...
    compile '[package]:[artifact]:[version, e.g. 0.1.2]'
}

Clean gradle cache

  • rm -rf ~/.gradle/caches
  • rm -rf [ProjectRoot]/.gradle
  • [ProjectRoot]/gradlew assemble

Fixing Logcat in Android Studio

  • Restart logcat (button on sidebar of Android Studio debugger panel)
  • Change the log level to Debug (or anything else) and back to Verbose.
  • Unplugging and plugging back in the device
  • Running adb kill-server && adb start-server
  • Close Android Studio and launch ddms on the command line.
  • Restart Android Studio
Clone this wiki locally