# How to setup android studio for pepper

This is a guide on pepper setup for android studio. This guide will show you how to setup android studio for pepper. To start off we will follow the provided guide on the [softbank website](https://qisdk.softbankrobotics.com/sdk/doc/pepper-sdk/ch1_gettingstarted/installation.html). This guide will only help with certain parts of the setup

It is important to note that multiple combinations of android studio and pepper sdk can work together. This guide will show you how to setup android studio for pepper sdk with the versions that worked for us.

## Installing the Pepper SDK plug-in

### Install Android Studio

To start off you need to install android studio. QiSDK recommends installing the latest stable version (version 3.4 or higher). In this guide we recommend using version 2021.1.1 You can download android studio [here](https://developer.android.com/studio/archive). It is recommended to always start up android studio as an administrator. This can be done by right clicking on the android studio icon and selecting `Run as administrator`.

### Get Android SDK and Build-Tools

Follow the first step on the QiSDK guide. Here are a few pointers to help you with this step:

- Android 6.0 (API level 23) is the minimum version required for the Pepper SDK. But it is not the version that will be used.
- The recommended version is Android 10.0 (API level 29). This is not shown as API 29 but as Android 10.0. This is the version that worked for us.

![Android 10](../assets/android10.png)

After this you can follow the rest of the guide on the QiSDK website.

### Robot SDK Manager

The option to simulate pepper and the tablet won't work. We have yet to find a solution for this. You can still create a device and run the app on the device. But you won't be able to simulate the robot.

## Creating a robot application

### Creating a project

To create a project you need to follow the steps on the QiSDK website. Here are a few pointers to help you with this step:

- Make sure to select a template that works for you. We recommend using the `Empty Activity` template. This will give you a blank project to start with.
- Make sure to select `Use legacy android.support libraries`. This will make sure that the project will work with the pepper sdk.

![Legacy](../assets/legacySetup.png)

- On step 5 of the guide make sure that the interface looks the following image, if it does not look the same gradle doens't recognize the project as an android project:

![Project structure interface](../assets/interfaceModules.png)

### Implementing QiSDK Design & the Robot Life Cycle

On this step the QiSDK guide provides you with a code snippet. This code snippet is used to make the robot do something. But the provided snipped makes use of the pepper library. This library is not included in the guide. To make use of the library you need to add the following line to the `settings.gradle` file:

```gradle
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        maven {
            url 'https://qisdk.softbankrobotics.com/sdk/maven/'
        }
    }
}
```

After this you should be able to make use of the pepper library. The imports of classes will show up red to solve this right click the imported class, there will be a option to import the class. Do this for all imports that are red. After this restart android studio and the imports should be fixed.

### Conclusion

The guide on the QiSDK website is a good guide to follow. But it is not complete. This guide is meant to help you with the parts that are not covered in the QiSDK guide. Once all steps from both guides are followed you should be able to run the app on the robot.