Link Menu Search Expand Document

Android

Table of contents

  1. AVD
    1. Create from CLI
  2. Get APK from Phone/Emulator
  3. Tools
  4. Installing / Updating Magisk
  5. Proxy/TCP forward
  6. Create AVD from command line

AVD

For all purposes, $ANDROID_SDK is the path to where the Android SDK is installed.

Create from CLI

First determine what system image you want to use with your AVD. In order to see a list of the available images run:

$ANDROID_SDK/tools/bin/sdkmanager --list

Check the one you want, and install it. For the example below I selected the image system-images;android-28;google_apis_playstore;x86_64.

$ANDROID_SDK/tools/bin/sdkmanager "system-images;android-28;google_apis_playstore;x86_64"

Create an AVD. This one will use the pixel_xl as the base device for it:

$ANDROID_SDK/tools/bin/avdmanager -v \
  create avd \
  -c 2048M \
  -p /path/to/store/avd/PixelXL-Android28-x86_64 \
  -n "PixelXL-Android28-x86_64" \
  -d pixel_xl \
  -k 'system-images;android-28;google_apis_playstore;x86_64'

Now edit the /path/to/store/avd/PixelXL-Android28-x86_64/config.ini file and add the following line to it to enable using your computer’s keyboard:

hw.keyboard=yes

Get APK from Phone/Emulator

First find out the name of the package you are looking for:

adb shell pm list packages

Then get the full path to where the APK is:

adb shell pm path <package_name>

For example, suppose you want to get the Microsoft Teams package, the package name is com.microsoft.teams.

adb shell pm path com.microsoft.teams

Which returns

package:/data/app/com.microsoft.teams-lghbfp74glgysnc5xyqq2g==/base.apk

Now just download the package:

adb pull /data/app/com.microsoft.teams-lghbfp74glgysnc5xyqq2g==/base.apk /tmp/teams.apk

Tools

dex2jar - https://github.com/pxb1988/dex2jar procyon - https://bitbucket.org/mstrobel/procyon jadx - https://github.com/skylot/jadx

Installing / Updating Magisk

  • Unlock your phone’s booloader
    • For the Pixel 3a this is:
      • Go to Settings -> About phone and tap the “Build Number” 10 times
      • Go back and go into System -> Advanced -> Developer options
      • Enable USB Debugging
      • Enable “OEM Unlocking”
      • Connect your phone to your PC
      • Run adb reboot bootloader
      • Wait for the phone to reboot into the bootloader
      • On the PC run fastboot flashing unlock
      • Confirm on the phone that you want to unlock the bootloader
  • Check what version of Android your phone is running
  • Go to https://developers.google.com/android/images and download the image for your version
  • Decompress the file and inside of it there will be another zip file
  • Decompress this other zip file and get the boot.img file from it
  • Put the boot.img file somewhere on your phone
  • Download Magisk Manager and install it on your phone
  • Open it and click the button to install Magisk
  • When asked, tell it to patch a boot image
  • Give it the path to the boot.img file you uploaded to the phone
  • Download the patched image from the phone to your pc (it will be displayed on the screen after MagiskManager finishes patching it)
  • Disable “Automatic System Updates” on the phone by going to “Settings -> Developer Options”
  • Disable “Automatic System Updates” on the phone by going to “Settings -> Developer Options”
  • Disable “Automatic System Updates” on the phone by going to “Settings -> Developer Options”
  • Reboot into fastboot mode (adb reboot bootloader)
  • Find out what boot partition to use: fastboot getvar current-slot
  • Flash the appropriate boot partition with the patched image: fastboot flash boot_X magisk_patched.img where X is the result from the previous step
  • Run fastboot reboot
  • Enjoy your phone running Magisk

Proxy/TCP forward

Enable global proxy:

adb shell settings put global http_proxy 192.168.0.2:8083
adb shell settings put global https_proxy 192.168.0.2:8083

Disable global proxy

adb shell settings delete global http_proxy
adb shell settings delete global global_http_proxy_host
adb shell settings delete global global_http_proxy_port
adb shell settings delete global https_proxy
adb shell settings delete global global_https_proxy_host
adb shell settings delete global global_https_proxy_port

Create AVD from command line

From the AndroidSdk folder, run the following command:

./tools/bin/avdmanager \
  -v create avd \
  -c 2048M \
  -p ~/avds/with-google-apis/PixelXL-Android27-x86 \
  -n 'PixelXL-Android27-x86' \
  -d pixel_xl \
  -k 'system-images;android-27;google_apis_playstore;x86'

Table of contents


Gilgalab Knowledge Base