How I can install Google APIs:22 so I can build a legacy android application via terminal?
Tags: help, android
Published: 2020-07-14 08:14:52

I try to build a legacy application, so I can run it via android emulator. The application is build using gradle, so I installed gradle and android build-tools.

I have installed command line tools from https://developer.android.com/studio/#downloads

I have updated both `PATH` and `ANDROID_HOME` enviromental variables to indicate the correct paths in Ubuntu 18.04:

```
$ echo $ANDROID_HOME
/home/pcmagas/tools

$ echo $PATH
/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:/home/pcmagas/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/home/pcmagas/go/bin:/home/pcmagas/tools/bin:/home/pcmagas/gradle-2.10/bin

```


Then I run:

```
gradle
```

And I got the following error:

```
Starting Build
Settings evaluated using settings file '/home/pcmagas/Kwdikas/mobile-client-android/settings.gradle'.
Projects loaded. Root project using build file '/home/pcmagas/Kwdikas/mobile-client-android/build.gradle'.
Included projects: [root project 'mobile-client-android', project ':etable', project ':facebookSDK', project ':invokeControls']
Evaluating root project 'mobile-client-android' using build file '/home/pcmagas/Kwdikas/mobile-client-android/build.gradle'.
Evaluating project ':app' using build file '/home/pcmagas/Kwdikas/mobile-client-android/etable/build.gradle'.
Creating configuration compile
Creating configuration apk
Creating configuration provided
Creating configuration wearApp
Creating configuration androidTestCompile
Creating configuration androidTestApk
Creating configuration androidTestProvided
Creating configuration androidTestWearApp
Creating configuration testCompile
Creating configuration testApk
Creating configuration testProvided
Creating configuration testWearApp
Creating configuration debugCompile
Creating configuration debugApk
Creating configuration debugProvided
Creating configuration debugWearApp
Creating configuration testDebugCompile
Creating configuration testDebugApk
Creating configuration testDebugProvided
Creating configuration testDebugWearApp
Creating configuration releaseCompile
Creating configuration releaseApk
Creating configuration releaseProvided
Creating configuration releaseWearApp
Creating configuration testReleaseCompile
Creating configuration testReleaseApk
Creating configuration testReleaseProvided
Creating configuration testReleaseWearApp
Parsing legacy package: /home/pcmagas/tools
Parsing legacy package: /home/pcmagas/tools

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> failed to find target with hash string 'Google Inc.:Google APIs:22' in: /home/pcmagas/tools

* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.

```

So how I can install the required `compileSdkVersion` tool according to this stackoverflow answer https://stackoverflow.com/a/35450642/4706711 so I can install the `Google APIs:22` SDK?

## Further update:

Following this stackoverflow answer I reinstalled android SDK now `ANDROID_HOME` and `PATH` environmental variables are:

```
echo $ANDROID_HOME
/home/pcmagas
$ echo $PATH
/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:/home/pcmagas/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/home/pcmagas/go/bin:/home/pcmagas/tools/bin:/snap/bin:/home/pcmagas/go/bin:/home/pcmagas/tools/bin:/snap/bin:/home/pcmagas/go/bin:/home/pcmagas/cmdline-tools/tools/bin

```

Also, I have set the following settings to `.bashrc` as well:

```
#Google SDK
export ANDROID_HOME=$HOME
PATH=$PATH:$ANDROID_HOME/cmdline-tools/tools/bin
```

I run afterwards:

```
sdkmanager  "platform-tools" "platforms;android-22"
```

Still, no light in my path.