32

I have the above error and have no clue why I still have it. I have reinstalled API 23 numerous times and done googling and the only fix I found was to reinstall the API but still have the issue.

Does anyone have a fix for it?

        apply plugin: 'com.android.application'

    android {
      compileSdkVersion 'Google Inc.:Google APIs:23'
      buildToolsVersion '23.0.2'

      defaultConfig {
        applicationId "com.example.app"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
      }

      lintOptions {
        disable 'InvalidPackage'
      }


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

    dependencies {
      compile fileTree(dir: 'libs', include: ['*.jar'])
      testCompile 'junit:junit:4.12'
      compile 'com.android.support:appcompat-v7:23.1.1'
      compile 'com.android.support:design:23.1.1'
      compile 'me.neavo:volley:2014.12.09'
      compile 'com.google.code.gson:gson:2.5'
      compile 'com.jakewharton:butterknife:7.0.1'
      compile 'com.android.support:support-v4:23.1.1'
    }
Stillie
  • 2,647
  • 6
  • 28
  • 50

7 Answers7

73

Try to use compileSdkVersion 23 instead of compileSdkVersion 'Google Inc.:Google APIs:23'

Vasily Kabunov
  • 6,511
  • 13
  • 49
  • 53
  • i am unable to do a sync, so i have to exit and open it again which then does the sync. the error is the same – Stillie Feb 17 '16 at 07:55
  • I'm 100% sure this fix solves your problem. I've tried to copy your string `compileSdkVersion 'Google Inc.:Google APIs:23'` to my project `build.gradle` and had the same error. Try to Clean and Rebuild your project – Vasily Kabunov Feb 17 '16 at 08:01
  • even after the change the error im getting is Error:Cause: failed to find target with hash string '23' in: – Stillie Feb 17 '16 at 08:16
  • 3
    thy to copy this string `compileSdkVersion 23`. You might use `compileSdkVersion '23'` (23 with apostrophes), it is not correct. – Vasily Kabunov Feb 17 '16 at 08:22
  • 2
    ah flip! blonde as hell moment! thanks a mill that worked! strange thing is, compileSdkVersion 'Google Inc.:Google APIs:23' works fine on my Mac laptop, i am doing work on a windows pc and downloaded the code from GIT which is identical to my laptop work and it failed here. Thanks again – Stillie Feb 17 '16 at 08:25
  • Is there a bug opened for this? – Utsav Gupta Dec 23 '16 at 13:12
  • In my case I had to change the line to compileSdkVersion 21 and it worked. You can look into the path it is giving in the error message which sdks you have installed. N.B. working with Win10, Android Studio 3.1.2, gradle-4.4.1. – karsten314159 Jun 16 '18 at 08:16
  • How do I install `compileSdkVersion` tool using cli-tools? – Dimitrios Desyllas Jul 14 '20 at 09:33
6

I got this error when trying to build a project on Windows that was originally built on Ubuntu. If you're not sure which build.gradle file is causing it and the project has multiple modules, do a project search for "compileSdkVersion."

Windows expects: compileSdkVersion 'Google Apis:Google Apis:23'

Ubuntu expects: compileSdkVersion "Google Inc.:Google APIs:23"

winchella
  • 162
  • 2
  • 11
4

Main module or any library must be using 'Google Inc.:Google APIs:23' which is not installed in SDK. So try to change it and compile

Change : compileSdkVersion 'Google Apis:Google Apis:23'

To : compileSdkVersion 23 (You should have android-23 installed in SDK)

Kushal
  • 8,100
  • 9
  • 63
  • 82
3

I got this error too, when i imported eclipse project to android studio. So i just did a little search "Edit -> Find -> Find in path" for "APIs 23" And i did replace (compileSdkVersion 'Google Inc.:Google APIs:23') in "Build.gradle" withe (compileSdkVersion 24). I think it should works. Good luck

Luky
  • 31
  • 1
1
Error:Cause: failed to find target with hash string 'Google Inc.:Google APIs:17' in: C:\Users\brahmaiah\AppData\Local\Android\Sdk

Open Android SDK Manager</a>

when i have been importing the proj of eclipse into android adt i faced same problem.but i rectrify throug the following content changing which is in gradle.build file.i.e. { compileSdkVersion 23 targetsdkVersion"23.0.1".}

brahmy adigopula
  • 617
  • 3
  • 15
1

You can create a new project and see what's written in this project's 'build.gradle'.For example it is 'compileSdkVersion 25',then change your target project to 'compileSdkVersion 23'.

Robin
  • 11
  • 2
1

I am using Ubuntu ,and I had the same issue. The accepted answer did not work for my version of Android Studio (2.3.3).

I had to import an Eclipse webapp project for Android SDK 15, and did receive the same message. The solution that worked for me was the following:

  1. Download the correct version of the Android SDK (version 15 in my case)
  2. Use the name of the directory folder (in my case "android-15" stored in my home folder at "~/[user_xxx]/Android/Sdk/platforms/".
  3. Edit the line in the gradle script in my case to : compileSdkVersion 'android-15'
pedda
  • 106
  • 7