I use rclone and sync my Android projects folder to Google Drive (it also supports One Drive and others).
You could do something similar, but do the entire Android Studio installation.
In my Android Studio launcher (studio.sh), I modify the file so that the project folder is synced from Google Drive to my hard drive on startup, and synced back to Google Drive on close down.
This is mainly because I do development on different computers.
My studio.sh looks something like below
#################################################
# Put the following at start of studio.sh file #
# Sync any new updated source files from GDrive #
#------------------------------------------------
rclone sync -L GDrive: home/me/AndroidStudioProjects
#################################################
# Put the following at end of studio.sh file #
# Sync files back to GDrive #
#------------------------------------------------
rclone sync -L home/me/AndroidStudioProjects GDrive:
The above will only work if rclone is in your execution path obviously, and also you have to be careful how you shut down Android Studio (close your project, then AS).
However, this works really nicely for me.
rclone also supports at rest encryption (which I use) so your project doesn't have to be in plaintext whilst in cloud storage, and it decrypts the data on the fly when you want to sync it back down.
It's an awesome free tool really.