0

I have been trying to solve this weird issue for 2 days now and i simply cant find the answer. I have looked on various different questions here but it seems to be a slightly different problem as im having.

My android studio works fine when I start a new app it renders the view and no issues.

When I import a app i need to work on it suddenly cant sync gradle and says the following:

Error:Cause: failed to find target with hash string 'android-22' in: E:\Android\sdk

My Android SDK is up to date all the tools are installed - see image below:

SDK Manager with tools 22 installed

Here is what I have done so far to try to get this import to show, im using a windows PC

  1. Uninstalled Android Studio and Re-installed the SDK
  2. Made sure that the ANDROID_HOME system variables and tool & platform paths are set - tested as can call "Android" from CMD and it loads the SDK
  3. Edited the build.Gradle file to target another SDK version - but it just says it cant find the new targeted version.

Is there some other things I can do to try get this app to import? As I know the app is working fine for other people...

Update gradle snippet

apply plugin: 'com.android.application'

android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
packagingOptions {

    exclude('META-INF/NOTICE')
}
packagingOptions {

    exclude('META-INF/LICENSE')
}
defaultConfig {
    applicationId "ru.ifsoft.network"
    minSdkVersion 15
    targetSdkVersion 22
    versionCode 12
    versionName '1.5'
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'),                'proguard-rules.pro'
    }
}
productFlavors {
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.mcxiaoke.volley:library:1.0.18'
compile('org.apache.httpcomponents:httpmime:4.3.6') {
    exclude module: 'httpclient'
}
compile 'org.apache.httpcomponents:httpclient-android:4.3.5'
compile 'com.android.support:recyclerview-v7:22.2.+'
compile 'com.github.chrisbanes.photoview:library:1.2.3'
compile 'com.google.android.gms:play-services:7.5.0'
compile 'com.facebook.android:facebook-android-sdk:4.0.1'
compile 'com.android.support:support-v4:22.2.1'
compile 'com.google.android.gms:play-services-gcm:7.5.0'
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.google.android.gms:play-services-ads:7.5.0'
compile 'com.pkmmte.view:circularimageview:1.1'
compile 'com.android.support:design:22.2.1'
compile 'com.melnykov:floatingactionbutton:1.3.0'
compile 'com.squareup.okhttp:okhttp:2.5.0'
 }

Thanks

Community
  • 1
  • 1
user1673498
  • 431
  • 1
  • 8
  • 26

3 Answers3

0

It looks that your project in Android Studio is point to the different SDK than is showing in your snapshot. Please check your local.properties and verify that relevent sdk has the desired platform.

Hope this helps.

Regards,

Mustansar Saeed
  • 2,730
  • 2
  • 22
  • 46
0

update your sdk with the latest build tools. and set your compile sdk to 22 if it supports. if not work then you have to clean and rebuild project

Hamees Arshad
  • 187
  • 1
  • 10
0

Note: I think this might be a bug in Android Studio.


As you have already installed all the necessary tools:

  1. Go to Project Structure
  2. Select App Module
  3. Under the first tab "Properties" change the Compile SDK Version to API XX from Google API xx (e.g. API 23 instead of Google API 23)
  4. Press OK
  5. Wait for the completion of on going process, in my case I did not get an error at this point.
  6. Now revert Compiled Sdk Version back to Google API xx.

If this not work, then:

  1. With Google API (Google API xx instead of API xx), lower the build tool version (e.g. Google API 23 and build tool version 23.0.1)
  2. Press Ok and wait for completion of on going process
  3. Revert back your build tool version to what it was before you changed
  4. Press Ok and Wait for the completion of process.
  5. Done!
Sagar Patel
  • 506
  • 1
  • 8
  • 23