https://github.com/hrafnthor/ansible-android-studio
An Ansible role for installing Android Studio
https://github.com/hrafnthor/ansible-android-studio
android android-studio ansible ansible-role linux
Last synced: about 2 months ago
JSON representation
An Ansible role for installing Android Studio
- Host: GitHub
- URL: https://github.com/hrafnthor/ansible-android-studio
- Owner: hrafnthor
- License: mit
- Created: 2022-12-21T18:20:57.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-03-11T12:33:03.000Z (over 2 years ago)
- Last Synced: 2025-03-14T03:27:26.023Z (over 1 year ago)
- Topics: android, android-studio, ansible, ansible-role, linux
- Homepage:
- Size: 11.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Ansible Android Studio
This role can download and configure multiple Android Studio clients for use on a Linux machine.
## Requirements
This role requires two separate tools be installed.
First it requires the `ansible.utils` collection be installed from Ansible-Galaxy via:
```bash
ansible-galaxy collection install ansible.utils
```
Secondly it requires the `jsonschema` Python package be installed via:
```bash
pip install jsonschema
```
## Role Variables
All parameters are optional unless otherwise stated.
```yaml
android_studio:
clients: A list of version definitions to install or remove.
- version: [string] [required] The version number for the Android Studio client to install.
codename: [string] See information below.
checksum: [string] [required] The checksum for the version number archive being installed. See information below.
remove: [bool] If true, no archive will be downloaded and any client matching the 'version' value will be removed.
desktop:
name: [string] The name to use for the desktop entry. Defaults to 'Android Studio '
remove: [bool] Indicates if the desktop entry should be removed
keywords: [array] Array of strings to add to the desktop entry for search filtering.
location: Allows for configuration of installation location.
path: [string] Defines the installation path for new studio clients.
owner: [string] Defines the owner of the installation path, otherwise 'root'.
group: [string] Defines the group owning the installation path, otherwise the same as 'owner'.
mode: [string] Defines the mode for the installation path, otherwise '0755'
environment: Allows for configuration of environment variables.
remove: [bool] If true, removes the file containing the environment variables.
location: Allows for configuration of the environment file location.
path: [string] Defines the path to where the environment file is located.
owner: [string] Defines the owner of the environment file.
group: [string] Defines the groupowning the environment file, otherwise the same as 'owner'.
jdk_path: Allows for configuration of 'STUDIO_JDK' variable
value: [string] [required] The value to set
remove: [bool] If true, will remove the variable.
sdk_path: Allows for configuration of 'ANDROID_HOME' variable.
value: [string] [required] The value to set
remove: [bool] If true, will remove the variable.
preferences_path: Allows for configuration of 'ANDROID_USER_HOME' variable.
value: [string] [required] The value to set
remove: [bool] If true, will remove the variable.
emulator_path: Allows for configuration of 'ANDROID_EMULATOR_HOME' variable.
value: [string] [required] The value to set
remove: [bool] If true, will remove the variable.
avd_path: Allows for configuration of 'ANDROID_AVD_HOME' variable.
value: [string] [required] The value to set
remove: [bool] If true, will remove the variable.
```
For version numbers and their associated checksums seem the archives [here](https://developer.android.com/studio/archive).
##### Codename
Used if the remote artifact is named using a different codename than just the version.
For example if the version is named 'android-studio-panda2-canary1-linux.tar.gz' instead of 'android-studio-2025.3.1.5-linux.tar.gz' then the codename should be set to 'panda2-canary1'. Otherwise the version will be used.
See Google's own archive page (linked above) for details.
### Defaults
By default the clients will be installed under `/opt/android/studio` as defined by the default variable `hth_android_studio_default_path`, unless the variable `android_studio.location.path` is given.
By default the location of the environment variables file is `/etc/profile.d/android.sh` as defined by the default variable `hth_android_studio_default_environment_path`, unless the variable `hth_android_studio.environment.location.path` is given.
By default all directories created will be owned by the user running the role, unless configured differently using variables such as `android_studio.location.owner | .group` or `android_studio.environment.location.owner | .group`. They are also given chmod `0755` by default.
By default the desktop file is placed at `/usr/share/applications` as defined by the default variable `hth_android_studio_default_desktop_file_path`.
By default the symlinks are placed in `/usr/bin` as defined by the default variable `hth_android_studio_default_symlink_path`, unless the variable `android_studio.(primary | canary).symlink.path` is given.
## Dependencies
None.
## Setup
Before the role can be used it needs to be added to the machine running the playbook, and as of writing this, this role is not hosted on Ansible-Galaxy only on Github.
1. Create a `requirements.yml` file in the root directory of the playbook being worked on.
2. Add the following definition inside the `requirements.yml` file:
```yml
- name: hth-android-studio
src: https://github.com/hrafnthor/ansible-android-studio.git
scm: git
```
3. Install the requirements by executing
```shell
ansible-galaxy install -r .requirements.yml
```
This will allow any playbook run from this machine to use the role `hth-android-studio`
## Example Playbook
The following playbook installs two clients. Each is installed to the default location, but with guid `developers`. One client is configured as the primary studio client, while the other one is set as the canary client. Each are given custom descriptive names and keywords. The canary client is symlinked only for user `Hrafn`. The environment file is create only for user `Hrafn`, with one incorrect value being removed.
```yaml
- hosts: all
vars:
android_studio:
clients:
- version: "2025.1.1.12"
checksum: "9aa40cdfd3de3c5616220ba4ccddd7e2b4c73d471dac54dcfce0bdc38b7ec093"
- version: "2025.1.2.6"
checksum: "04e529e084b3e5001d94420b1233967b2526bbf54755f82b4be02c08ca359fbd"
primary:
version: "2025.1.1.12"
symlink:
name: "astudio"
desktop:
name: "Primary"
keywords:
- "android"
- "studio"
- "primary"
canary:
version: "2025.1.2.6"
symlink:
name: "astudioc"
path: "/home/hrafn/.local/bin"
desktop:
name: "Canary"
keywords:
- "android"
- "studio"
- "canary"
location:
group: "developers"
mode: "2775"
environment:
location:
path: "/home/hrafn/.env.d"
owner: "hrafn"
group: "hrafn"
jdk_path:
value: "/tmp/not-correct-path/bin"
remove: true
sdk_path:
value: "/usr/lib/android/sdk"
preferences_path:
value: "$HOME/.android"
emulator_path:
value: "$HOME/.android/emulators"
avd_path:
value: "$HOME/.android/avd"
roles:
- hth-android-studio
```
## License
```
Copyright 2025 Hrafn Thorvaldsson
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```