Guide to setup JetBrains Projector and access Android Studio from any device

Overview

JetBrains Projector with Android Studio

Guide to setup JetBrains Projector and access Android Studio from any device.

Blog post

Android Studio on iPad Pro Android Studio on an iPad Pro

Step 1: Spin up a Linux server

This guide will explain how to get a virtual machine setup with Amazon AWS, but you can choose any other provider like Google Cloud or Microsoft Azure, or even a machine on your local network.

  1. Make a AWS account and login
  2. Go to the EC2 section and select create a new Instance
  3. Search for "Debian" in the AWS Marketplace and choose the latest Debian distribution (Debian 10 Buster at the time of writing)
  4. Pick the instance type, I suggest one with at least 8Gb RAM, preferrably more
  5. Click next until you get to storage, and choose how much storage you need. I suggest at least 20Gb (you can always expand this later)
  6. Click next until the security section, you need to add a new rule to be able to access the port that Projector will use
  • Add a new custom TCP rule with port 8888 (or any port you like, will be useful in the next step)
  • If you want to secure access, you can choose to only allow connections only from your own IP adress (recommended): Source > My Ip
  1. Choose or create a private key to access the instance and start it
  2. Write down the IP addresss (ipv4) shown in the EC2 console

Step 2: Connect to your remote server via SSH

  1. To make it easy to connect to your instance, create a new file ~/.ssh/config (if it doesn't exist already)
  2. Add a new host to your ~/.ssh/config:
Host {REMOTE_MACHINE_ALIAS}
  User {REMOTE_MACHINE_USERNAME}
  HostName {REMOTE_MACHINE_IP_OR_HOSTNAME}
  Port 22
  IdentityFile ~/.ssh/{SSH_KEY_NAME}
  PreferredAuthentications publickey
  ControlMaster auto
  ControlPath /tmp/%r@%h:%p
  ControlPersist 1h
  • Host - Choose an alias like remote-builder or anything you like
  • User - By default, the username for a Debian server is admin
  • Hostname - the IP address of your EC2 instance
  • IdentityFile - the path to your private key file downloaded when creating the EC2 instance
  1. Now you can connect to your machine easily like this
$ ssh remote-builder
  1. Once connected, you can now begin installing things on your remote server

Note: when you're done, remember to stop your AWS instance to stop being charged!

Step 3: Install Projector and Android Studio on the remote server

  1. To install Projector (and dependencies), run the following commands:
$ sudo apt-get update
$ sudo apt install python3 python3-pip
$ sudo apt install libxext6 libxrender1 libxtst6 libfreetype6 libxi6
$ pip3 install projector-installer
  1. Projector is now installed, you can see all options by running
projector --help
  1. At this point, you could run one of the pre-configured IDEs like IntelliJ and start using it, but to run Android Studio, you need to install it separately.
  2. Download the latest Android Studio Arctic Fox or above (Arctic Fox is the minimum version that works with Projector)
  • Find the latest download URL for linux from https://developer.android.com/studio/archive. At the time of writing, the latest version is Artic Fox Patch 2
  • Download it to your remote server in your home directory with curl:
$ curl -L --output android-studio.tar.gz https://redirector.gvt1.com/edgedl/android/studio/ide-zips/2020.3.1.24/android-studio-2020.3.1.24-linux.tar.gz
  • Unzip the downloaded archive:
$ tar -xvf android-studio.tar.gz
  1. You now have Android Studio installed, all that is left is to configure Projector, making sure to select the port that was chosen as the custom TCP rule for the VM (step 1.6) - here we're using port 8888. When asked to use a secure connection, I recommend saying yes to ensure copy pasting functionality works properly.
$ projector config add
Enter a new configuration name: AndroidStudio
Do you want to choose a Projector-installed IDE? [y/n]: n
Enter the path to IDE: /path/to/your/android-studio
Enter a desired Projector port (press ENTER for default) [10005]: 8888
Use secure connection (this option requires installing a projector's certificate to browser)? [y/n]: y
  1. This will start Android Studio with Projector on port 8888. Next time you want to start it, you can just run:
$ projector run AndroidStudio

Step 4: Access Android Studio from a Browser

  1. On your local machine, start a browser and go to http://<your_server_ip>:8888
  2. If you've chosen "use secure connection" you'll get a warning saying the certificate is unknown, select proceed anyways
  3. Enjoy your remote Android Studio!

Optional: Setup ADB to deploy to / debug a local device

  1. You need to have the same version of adb on the remote and local machine
$ adb -- version
Android Debug Bridge version 1.0.41
Version 30.0.4-6686687
  1. Kill adb on both local and remote machines if it was already running
$ adb kill-server
  1. On the local machine, with an Android device connected, run:
$ adb devices
List of devices attached
  ABCDEF12345
$ ssh -R 5037:localhost:5037 remote-builder
  1. This will connect to your instance with port forwarding enabled. Now check that the device is visible on the remote machine:
$ adb devices
List of devices attached
  ABCDEF12345
  1. That's it! Both machines can now run adb commands and everything will be redirected to the local phone.
  2. To always connect to your instance with adb port forwarding (port 5037 by default), you can add the following line to your ~/.ssh/confg:
RemoteForward 5037 localhost:5037

Script to facilitate the entire workflow

This is the home made script I use. It takes care of starting my EC2 instance which I gave a static IP adress to, starting Projector in a tab-less Chrome and stopping the EC2 instance when I exit Chrome. Put this in a bash script, like work.bash and run it. The script uses the aws CLI, which you will have to setup beforehand (documentation). Make sure to replace the placeholder instance ids with your own.

#!/bin/bash
INSTANCE_ID=<your_instance_id>
STATIC_IP=<your_instance_static_ip>
PORT=8888

echo "Starting Server..."
aws ec2 start-instances --instance-ids $INSTANCE_ID
aws ec2 wait instance-running --instance-ids $INSTANCE_ID
echo "Server Started"
adb devices
ssh -o 'ConnectionAttempts 10' remote-builder "/home/admin/.local/bin/projector run AndroidStudio" &
sleep 5
echo "Projector started, opening browser..."
open -W -na "Google Chrome" --args --new-window --app="https://$STATIC_IP:8888/?host=$STATIC_IP&port=$PORT"
echo "Stopping Server..."
aws ec2 stop-instances --instance-ids $INSTANCE_ID
aws ec2 wait instance-stopped --instance-ids $INSTANCE_ID
echo "Done"

If you don't want to give a static IP address to your EC2 instance, you can get the generated IP automatically with the aws CLI, which removes the need for having a .ssh/config file altogether. This is what the modified script looks like (Thanks @Clement-Jean for the tip!):

#!/bin/bash

INSTANCE_ID=<your_instance_id>
PORT=8888
USER=admin
REGION=<your_instance_region>

echo "Starting Server..."
aws ec2 start-instances --instance-ids $INSTANCE_ID
aws ec2 wait instance-running --instance-ids $INSTANCE_ID
echo "Server Started"
IP=`aws ec2 describe-instances --instance-ids $INSTANCE_ID --query 'Reservations[*].Instances[*].PublicIpAddress' --output text`
EC2_IP=`echo $IP | sed 's/\./-/g'`

adb devices
ssh -o 'ConnectionAttempts 10' -i <your_pem_file_path> $USER@ec2-$EC2_IP.$REGION.compute.amazonaws.com "/home/$USER/.local/bin/projector run AndroidStudio" &
sleep 5
echo "Projector started, opening browser..."
open -W -na "Google Chrome" --args --new-window --app="https://$IP:8888/?host=$IP&port=$PORT"
aws ec2 stop-instances --instance-ids $INSTANCE_ID
aws ec2 wait instance-stopped --instance-ids $INSTANCE_ID
echo "Done"

Useful links and other installation methods

Main Projector README

Projector Docker Image

Projector Installer Repo

Projecter Server Repo

You might also like...
DogglersApp - Criação de um App para estudo de RecyclerView no Android Studio. Parte do curso Android Basics in Kotlin

Dogglers - Starter Code Starter code for the second independent project for Android Basics in Kotlin. Introduction This is the starter code for the Do

These files are included in an Android Studio Project for a Magic the Gathering Life Counter app. The app was written in Kotlin.
These files are included in an Android Studio Project for a Magic the Gathering Life Counter app. The app was written in Kotlin.

Magic-Life-Counter These files were created in Android Studio using Kotlin. Usage This app was made to keep track of life totals while playing the tra

An e-commerce mobile application built using Android Studio + Java + Firebase.
An e-commerce mobile application built using Android Studio + Java + Firebase.

E-Commerce An e-commerce mobile application built using Android Studio + Java + Firebase. Login for : [email protected] 123456 Screenshots of the app : L

Open currenty activity in Android Studio

Open Current Activity Android Studio / IntelliJ Plugin A little plugin for Android development (Android Studio or IntelliJ). Adds an action under Navi

A women safety project built in Android Studio.
A women safety project built in Android Studio.

⚡ Spark Women - A Women Safety Application Feel Safe Everywhere Women Safety App is user friendly application built in Android Studio, it is simple to

Simple App made for a test to Studio Sol Company

Studio Sol Test - Guess the Number Simple App made for a test to Studio Sol Company. #What you'll see in this project: ViewBinding Navigation Animatio

  An IoT based automatic alerting device that consists of laser and a precise Light Dependent Resistor to detect the laser which is employed to constantly monitor the fluid level
An IoT based automatic alerting device that consists of laser and a precise Light Dependent Resistor to detect the laser which is employed to constantly monitor the fluid level

An IoT based automatic alerting device that consists of laser and a precise Light Dependent Resistor to detect the laser which is employed to constantly monitor the fluid level. When the fluid level is below the critical level which will be defined by laser, it will alert the patient through buzzer, nurses and doctors through mobile app and the …

Browse your memories without any interruptions with this photo and video gallery
Browse your memories without any interruptions with this photo and video gallery

Simple Gallery Simple Gallery Pro is a highly customizable lightweight gallery loved by millions of people for its great user experience. Organize and

Comments
  • Non Static IP script

    Non Static IP script

    You might want to add a script for non static IP instance. Should look like something like this:

    #!/bin/bash
    
    INSTANCE_ID=<your_instance_id>
    PORT=8888
    USER=root
    REGION=<your_instance_region>
    
    echo "Starting Server..."
    aws ec2 start-instances --instance-ids $INSTANCE_ID
    aws ec2 wait instance-running --instance-ids $INSTANCE_ID
    echo "Server Started"
    IP=`aws ec2 describe-instances --instance-ids $INSTANCE_ID --query 'Reservations[*].Instances[*].PublicIpAddress' --output text`
    EC2_IP=`echo $IP | sed 's/\./-/g'`
    
    adb devices
    ssh -o 'ConnectionAttempts 10' -i <your_pem_file_path> $USER@ec2-$EC2_IP.$REGION.compute.amazonaws.com "/home/$USER/.local/bin/projector run AndroidStudio" &
    sleep 5
    echo "Projector started, opening browser..."
    google-chrome --new-window http://$IP:$PORT/
    aws ec2 stop-instances --instance-ids $INSTANCE_ID
    aws ec2 wait instance-stopped --instance-ids $INSTANCE_ID
    echo "Done"
    

    And no need for the config file

    opened by Clement-Jean 2
  • Accessing IDE run on another machine

    Accessing IDE run on another machine

    What if you need access to the IDE on another computer connected to the same network? You need to find out the IP address of the one connected to the network and change it thus http: // localhost: 8887 /? Host = ip & port = 8887?? But the other computer cannot access. Explain this point in more detail.

    opened by nailshakurov 0
  • projector

    projector

    To contribute to the documentation. But first of all thanks to experiment for us about intelliJ projector in Android Studio. If i set an instance of Debian with let's say AWS, instead to go through the installer can i use also the plugin mode instead of the installer you suggest? https://github.com/JetBrains/projector-server/tree/master/projector-plugin to run a stable Android studio version and not 4.2 canary? I see in the link of the plugin above is specified java 11 to run the gradle plugin building from sources, but I am wondering if is necessary.

    I mean in the worst scenario the plugin will not work I guess if I do an aws account should work AS with a linux GUI(gnome, kde, i3wm), although I guess is less responsive without projector right?

    opened by Ndrocchietto 0
Owner
Joaquim Verges
Android fanatic
Joaquim Verges
Automatically generates UI demos which allow users to call any function with any parameters

Automatically generates UI demos which allow users to call any function (including composable ones) with any parameters. Useful for building demo screens in playground apps of various design systems.

Anton Popov 3 Jul 28, 2022
Spring Boot project scaffold written in Kotlin, which is based on the Official Guide.

Kotlin-Spring-Boot Spring Boot project scaffold written in Kotlin, which is based on the Official Guide. Development environment Windows choco install

idea2app 1 Feb 27, 2022
A Tachidesk Desktop UI built in JetBrains Compose

TachideskJUI A free and open source manga reader to read manga from a Tachidesk server. TachideskJUI can run the Tachidesk server on its own, or conne

null 226 Jan 6, 2023
My nineteenth Kotlin project from JetBrains Academy

Connect Four Stage 5 of 5 for JetBrains Academy - Kotlin - Connect Four project. This stage has us add the option for more than one game ( and keeping

Danny 1 Oct 10, 2021
Mis experimentos con Kotlin para JetBrains Academy, certificación de Kotlin donde voy resolviendo proyectos de evaluación y haciendo actividades de cada tema.

Kotlin Academy Mis experimentos con Kotlin para JetBrains donde voy resolviendo proyectos de evaluación y haciendo actividades de cada tema. Acerca de

José Luis González Sánchez 1 Jan 10, 2022
Jugando con un Parking realizado como prueba de examen en JetBrains Academy, curso Kotlin Developer

Kotlin Parking Lot Proyecto de evaluación para el título de Kotlin Developer en Jetbrains Academy. Consiste en realizar un parking con las especificac

José Luis González Sánchez 1 Jan 10, 2022
>On this day< is a JetBrains Space app which shows Wikipedia-based information about what happened on that or given day

kotlin-spaces-app-onthisday On this day is a JetBrains Space app which shows Wikipedia-based information about what happened on that or given day Stat

Tobias Scholze 2 Oct 20, 2022
Event State Processor Generator plugin is compatible with IntelliJ and Android Studio.

Event State Processor Generator plugin is compatible with IntelliJ and Android Studio. It provides source code generation for the EventStateProcessor Library to increase code productivity in Flutter apps development.

Extreme Vietnam Public 2 Dec 7, 2021
SeatBookView is an Android Studio Library that helps to make it easier to create Bus, Train, Cinema Theater Seat UI and all functionalities are given.

SeatBookView SeatBookView is an Android Studio Library that helps to make it easier to create Bus ?? , Train ?? , Cinema Theater Seat UI and all funct

Md. Zahidul Islam 3 Oct 15, 2022
Meu primeiro aplicativo Android desenvolvido com Kotlin e Android Studio.

Cálculos 3 em 1 Este é um aplicativo Android que oferece três tipos de cálculos: calcular o IMC, calcular o valor do IPVA e converter medidas. Esse ap

Viviane Bresolin 0 Oct 30, 2021