2

My build.gradle afer updating it look like this. And it gives me the error.

buildscript {
repositories {
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:2.2.0'
}
}
android {
compileSdkVersion 21
buildToolsVersion '23.0.3'
}
 allprojects {
repositories {
    jcenter()
}
}

earlier it looks like this

buildscript {
repositories {
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:2.2.0'
}
}

allprojects {
repositories {
    jcenter()
}
}

And that gave me this error -

  Error:Failed to find target with hash string 'Google Inc.:Google APIs:21' in: 
   /Users/abc/Library/Android/sdk
  <a href="openAndroidSdkManager">Open Android SDK Manager</a>

Don't know how to to get it fix. Please help just try to run app with components

Also checked all the possible solution. Possible duplicate

failed to find target with hash string 'android-22' Could not find method android() for arguments

cole
  • 3,147
  • 3
  • 15
  • 28

1 Answers1

1

Add the below lines in app build.gradle, not in your project top level build.gradle.

android {
   compileSdkVersion 21
   buildToolsVersion '23.0.3'
}

In the left pane, select 'Project' view. Under ProjectName/app/ you will find a build.gradle file. Add the above lines in that file, and remove it from your top level build.gradle file.

Bob
  • 13,447
  • 7
  • 35
  • 45
  • Happy to help. If it's working would you please upvote and mark it correct. – Bob Aug 11 '17 at 14:44
  • It takes atleast 5 minutes to do so. Also please upvote my question as well. So more people can see the question – cole Aug 11 '17 at 14:49