Error in MainActivity.java - R: Gradle sync failed: Failed to find target with hash string 'android-27

0

package com.example.diseo.example1;

import android.support.v7.app.AppCompatActivity; import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

}

ERROR: 10:32 AM Gradle sync failed: Failed to find target with hash string 'android-27' in: C: \ Android \ Sdk

Consult IDE log for more details (Help | Show Log) (618ms)

BUILD GRADE:

apply plugin: 'com.android.application'
    
    android {
        compileSdkVersion 27
        defaultConfig {
            applicationId "com.example.diseo.ejemplo1"
            minSdkVersion 15
            targetSdkVersion 27
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }
    
    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation 'com.android.support:appcompat-v7:27.1.0'
        implementation 'com.android.support.constraint:constraint-layout:1.1.3'
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'com.android.support.test:runner:1.0.2'
        androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    }

    
asked by Carlos 03.09.2018 в 17:40
source

2 answers

0

The problem

  

Gradle sync failed: Failed to find target with hash string   'android-27' in

indicates that you do not have version 27 of the SDK installed for this reason your project can not be built, go to SDK Manager

Select version 27 and click on "apply":

in this way the installation will be done:

    
answered by 03.09.2018 в 20:23
0

In my case I had this Manifest tag that gave that error, which was from an example of search diccionary   <uses-sdk android: minSdkVersion = "15" android: targetSdkVersion = "27" /> , Then delete it and synchronize and it worked fine. Then update that label as it should go

    <uses-sdk android: minSdkVersion = "15" android: targetSdkVersion = "27" />
    
answered by 21.10.2018 в 06:11