Failed to set up SDK: Error:Module \'app\': platform \'Google Inc.:Google APIs:21\' not found.
At a complete loss as to why this isn\'t working. Attemp
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:
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.
my problem was in my build.gradle ! when I opened It was like this :
android {
compileSdkVersion 'Google Inc.:Google APIs:21'
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.pixelnx.sam.allinone_room"
minSdkVersion 21
targetSdkVersion 21
How fixed it ?!
'Google Inc.:Google APIs:21'
and write 29 instead of it 2.set 29 for targetSdkVersion
RESULT :
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.pixelnx.sam.allinone_room"
minSdkVersion 21
targetSdkVersion 29
When it failed for me I downloaded Google API's, just as @Daniel Segato explains, which is the right thing to do, and still I got the message once and again and again.
Until I did this. I opened the module's settings (Ctrl + Alt + Shift + S
or File > Project Structure) and, for my module, I changed the Compile Sdk Version option to any other from the list. I resynchornized gradle and then changed the option back to Google APIs (API 23). And then it worked! It's really really really nasty of Android Studio not to recognize the SDK until you change it in that dialog box. But this only happened to me once. Other times it was enough just to download the proper Google API and there you go! But this is nasty.
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'
}
}
}