Android Studioで「Failed to resolve: com.android.support:appcompat-v7:27.+」

現象

久しぶりにAndroid Studio2.3.3を起動し、New Projectを作って初回Gradle Syncが実行されると、以下のメッセージが表示された。

Error:(26, 13) Failed to resolve: com.android.support:appcompat-v7:27.+
Install Repository and sync project
Show in File
Show in Project Structure dialog

ああ、sdkマネージャーに27が入ってないのね、と思いインストールするがエラーは直らず。

解決方法

プロジェクトルートのbuild.gradleを開いて+の行を追加する。

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
+        maven {
+            url 'https://maven.google.com/'
+            name 'Google'
+        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

再度syncするとエラーが消えた、解決!

前からNew Projectでこんなの手で入門する必要あったっけ?