Failed to set up SDK: Error:Module 'app': platform 'Google Inc.:Google APIs:21' not found

You can use compileSdkVersion 21 instead of yours .

    android {
    compileSdkVersion 21
    buildToolsVersion '21.1.2'

    defaultConfig {
        applicationId "com.elgami.customizer"
        minSdkVersion 14
        targetSdkVersion 21
    }

    buildTypes {
        release {
            minifyEnabled false
            //runProguard false
            //proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

The (currently accepted) answer that suggest replacing Google Inc.:Google APIs:21 with 21 is NOT suitable if you have some legacy app still using Google Map v1 (for example).

If you are in this situation you REALLY need to compile against Google Inc.:Google APIs:21 or 23 etc...

The solution here is to

Step 1

Open the old SDK manager interface clicking the Launch Standalone SDK Manager link below the Android Studio SDK Manager or by executing ${ANDROID_SDK_DIR}/tools/android sdk from command line to open it directly.

Then locate Google APIs for the SDK version you need and install it:

screenshot of the SDK Manager

That package is hidden, for some reason, inside Android Studio and I expect Google will remove it at some point. Currently the SDK 24 one (Marshmallow) is available but the 25 (Nougat) is not, they may add it in the future, or not. We will have to wait and see.

If you are in this situation and Google decide to stop providing it you'll have to rewrite the functionality using maps v2.

Step 2

Even after doing this and cleaning + gradle resync you'll get this error From Android Studio:

Cannot find System Java Compiler. Ensure that you have installed a JDK (not just a JRE) and configured your JAVA_HOME system variable to point to the according directory.

But it will compile if you try to do it from the command line (./gradlew assembleDebug).

The reason has apparently something to do with the Android Studio embedded Java JRE. To make it compile inside Android Studio open the Project Structure from Android Studio and provide a custom path for a JDK you installed on your system (you must install a OpenJDK / OracleJDK on your computer).

NOTE: it may be needed to navigate to the location instead of copying the path for Android studio to take the change. Do not pick the jre directory, pick the JDK (folder containing jre).

WARNING: this change is not specific to the project but will be applied to Android Studio itself and used on any other project.