Skip to content

Instantly share code, notes, and snippets.

@madhums
Last active November 22, 2023 12:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save madhums/dd335b8c9aefdc8bc42babe1f4cc5fa2 to your computer and use it in GitHub Desktop.
Save madhums/dd335b8c9aefdc8bc42babe1f4cc5fa2 to your computer and use it in GitHub Desktop.
install android sdk on linux (without installing android studio)
  1. Download commandline tools from https://developer.android.com/studio (You will find "Command line tools only" section at the bottom of the page)

  2. Place this in ~/Android/sdk/cmdline-tools/latest (the latest forlder should contain the contents of cmdline-tools that you downloaded above with the bin and lib directories)

  3. Then download the sdk using the cmdline-tools you downloaded

    cd ~/Android/sdk/cmdline-tools/latest/bin
    # this downloads android sdk and places everything in the ~/Android/sdk dir
    ./bin/sdkmanager "system-images;android-32;google_apis;x86_64" "platform-tools" "build-tools;33.0.2" "platforms;android-33-ext5" "emulator" --sdk_root=$HOME/Android/sdk
  4. Set ANDROID_HOME and expose paths of downloaded sdk executables

    echo 'export ANDROID_HOME=$HOME/Android/sdk' >> ~/.zshrc
    echo 'export PATH=${PATH}:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools:$ANDROID_HOME/emulator' >> ~/.zshrc
  5. Now you may create an emulator

    avdmanager create avd -n <EMULATOR_NAME> -k "system-images;android-32;google_apis;x86_64" -d pixel_7_pro
    # pixel_7_pro is the id of the device but you can select whichever you prefer by choosing from `avdmanager list``
  6. Feel free to use the config below (it has higher ramSize, enabled hardware buttons and some other optimisations for better DX)

# ~/.android/avd/<NAME_OF_AVD>/config.ini
PlayStore.enabled = no
abi.type = x86_64
avd.id = <build>
avd.ini.encoding = UTF-8
avd.name = <build>
disk.cachePartition = yes
disk.cachePartition.size = 66MB
disk.dataPartition.path = <temp>
disk.dataPartition.size = 6442450944
disk.systemPartition.size = 0
disk.vendorPartition.size = 0
fastboot.forceChosenSnapshotBoot = no
fastboot.forceColdBoot = no
fastboot.forceFastBoot = yes
hw.accelerometer = yes
hw.accelerometer_uncalibrated = yes
hw.arc = no
hw.arc.autologin = no
hw.audioInput = no
hw.audioOutput = yes
hw.battery = yes
hw.camera.back = emulated
hw.camera.front = none
hw.cpu.arch = x86_64
hw.cpu.ncore = 4
hw.dPad = no
hw.device.hash2 = MD5:a8abfd3536f3d35e4ba2041a7b99f40e
hw.device.manufacturer = Google
hw.device.name = pixel_7_pro
hw.display1.density = 0
hw.display1.flag = 0
hw.display1.height = 0
hw.display1.width = 0
hw.display1.xOffset = -1
hw.display1.yOffset = -1
hw.display2.density = 0
hw.display2.flag = 0
hw.display2.height = 0
hw.display2.width = 0
hw.display2.xOffset = -1
hw.display2.yOffset = -1
hw.display3.density = 0
hw.display3.flag = 0
hw.display3.height = 0
hw.display3.width = 0
hw.display3.xOffset = -1
hw.display3.yOffset = -1
hw.displayRegion.0.1.height = 0
hw.displayRegion.0.1.width = 0
hw.displayRegion.0.1.xOffset = -1
hw.displayRegion.0.1.yOffset = -1
hw.displayRegion.0.2.height = 0
hw.displayRegion.0.2.width = 0
hw.displayRegion.0.2.xOffset = -1
hw.displayRegion.0.2.yOffset = -1
hw.displayRegion.0.3.height = 0
hw.displayRegion.0.3.width = 0
hw.displayRegion.0.3.xOffset = -1
hw.displayRegion.0.3.yOffset = -1
hw.gltransport = pipe
hw.gltransport.asg.dataRingSize = 32768
hw.gltransport.asg.writeBufferSize = 1048576
hw.gltransport.asg.writeStepSize = 4096
hw.gltransport.drawFlushInterval = 800
hw.gps = yes
hw.gpu.enabled = yes
hw.gpu.mode = auto
hw.gsmModem = yes
hw.gyroscope = yes
hw.initialOrientation = portrait
hw.keyboard = yes
hw.keyboard.charmap = qwerty2
hw.keyboard.lid = yes
hw.lcd.backlight = yes
hw.lcd.circular = false
hw.lcd.density = 560
hw.lcd.depth = 16
hw.lcd.height = 3120
hw.lcd.vsync = 60
hw.lcd.width = 1440
hw.mainKeys = yes
hw.multi_display_window = no
hw.ramSize = 4096M
hw.rotaryInput = no
hw.screen = multi-touch
hw.sdCard = yes
hw.sensor.hinge = no
hw.sensor.hinge.count = 0
hw.sensor.hinge.fold_to_displayRegion.0.1_at_posture = 1
hw.sensor.hinge.sub_type = 0
hw.sensor.hinge.type = 0
hw.sensor.roll = no
hw.sensor.roll.count = 0
hw.sensor.roll.resize_to_displayRegion.0.1_at_posture = 6
hw.sensor.roll.resize_to_displayRegion.0.2_at_posture = 6
hw.sensor.roll.resize_to_displayRegion.0.3_at_posture = 6
hw.sensors.gyroscope_uncalibrated = yes
hw.sensors.heart_rate = no
hw.sensors.humidity = yes
hw.sensors.light = yes
hw.sensors.magnetic_field = yes
hw.sensors.magnetic_field_uncalibrated = yes
hw.sensors.orientation = yes
hw.sensors.pressure = yes
hw.sensors.proximity = yes
hw.sensors.rgbclight = no
hw.sensors.temperature = yes
hw.sensors.wrist_tilt = no
hw.trackBall = no
hw.useext4 = yes
image.sysdir.1 = system-images/android-32/google_apis/x86_64/
kernel.newDeviceNaming = autodetect
kernel.supportsYaffs2 = autodetect
runtime.network.latency = none
runtime.network.speed = full
sdcard.size = 512 MB
showDeviceFrame = yes
tag.display = Google APIs
tag.id = google_apis
test.delayAdbTillBootComplete = 0
test.monitorAdb = 0
test.quitAfterBootTimeOut = -1
vm.heapSize = 1024M
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment