困っていること
Firebaseを利用している古いプロジェクト(最初のコミットが2015年11月、最終更新が2019年5月)をAndroid Studio3.6.1でビルドしましたが、エラーが出てビルドができません。
また、エラー内容で
Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.6.1/gradle-3.6.1.pom'
とあるのですが、ブラウザでこのURLにアクセスするとgradle-3.6.1.pomがちゃんとダウンロードされました。
AndroidStudioのバージョン
Android Studio 3.6.1
現在発生しているエラー
A problem occurred configuring root project 'xxxxxxx'. > Could not resolve all artifacts for configuration ':classpath'. > Could not resolve com.android.tools.build:gradle:3.6.1. Required by: project : > Could not resolve com.android.tools.build:gradle:3.6.1. > Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.6.1/gradle-3.6.1.pom'. > Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.6.1/gradle-3.6.1.pom'. > Remote host closed connection during handshake > Could not resolve com.android.tools.build:gradle:3.6.1. > Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.6.1/gradle-3.6.1.pom'. > Could not GET 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.6.1/gradle-3.6.1.pom'. > Remote host closed connection during handshake > Could not resolve com.android.tools.build:gradle:3.6.1. > Could not get resource 'https://repo.maven.apache.org/maven2/com/android/tools/build/gradle/3.6.1/gradle-3.6.1.pom'. > Could not GET 'https://repo.maven.apache.org/maven2/com/android/tools/build/gradle/3.6.1/gradle-3.6.1.pom'. > Remote host closed connection during handshake > Could not resolve com.google.gms:google-services:4.3.3. Required by: project : > Could not resolve com.google.gms:google-services:4.3.3. > Could not get resource 'https://dl.google.com/dl/android/maven2/com/google/gms/google-services/4.3.3/google-services-4.3.3.pom'. > Could not GET 'https://dl.google.com/dl/android/maven2/com/google/gms/google-services/4.3.3/google-services-4.3.3.pom'. > Remote host closed connection during handshake > Could not resolve com.google.gms:google-services:4.3.3. > Could not get resource 'https://jcenter.bintray.com/com/google/gms/google-services/4.3.3/google-services-4.3.3.pom'. > Could not GET 'https://jcenter.bintray.com/com/google/gms/google-services/4.3.3/google-services-4.3.3.pom'. > Remote host closed connection during handshake > Could not resolve com.google.gms:google-services:4.3.3. > Could not get resource 'https://repo.maven.apache.org/maven2/com/google/gms/google-services/4.3.3/google-services-4.3.3.pom'. > Could not GET 'https://repo.maven.apache.org/maven2/com/google/gms/google-services/4.3.3/google-services-4.3.3.pom'. > Remote host closed connection during handshake
やったこと
- google-services.jsonをダウンロードしてアプリディレクトリの中に配置しました。
- 以下の通り、gradle-wrapper.propertiesとプロジェクトレベル・アプリレベルのbuild.gradleをそれぞれ修正しました。(...は省略、xxxは伏せ字です。)
####gradle-wrapper.properties
distributionUrl = https\://services.gradle.org/distributions/gradle-4.4-all.zip ↓ distributionUrl = https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
プロジェクトレベル build.gradle
buildscript { repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.6.1' //バージョンを3.1.3->3.6.1に修正 classpath 'com.google.gms:google-services:4.3.3' //バージョンを4.0.2->4.3.3に修正 ... } } ...
アプリレベル build.gradle
android { compileSdkVersion 28 buildToolsVersion '28.0.3' //27.0.3→28.0.3に変更 defaultConfig { applicationId "jp.co.xxx.xxx.xxx.xxxx" minSdkVersion 16 //14→16に変更 targetSdkVersion 28 //26→28に変更 versionCode 28 versionName "x.x.x" } ... productFlavors { xxxxx { minSdkVersion 16//14→16に変更 targetSdkVersion 28 //26→28に変更 } } ... dependencies { ... implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support:support-v4:28.0.0' implementation 'com.android.support:recyclerview-v7:28.0.0' implementation 'com.android.support:design:28.0.0' implementation 'com.google.firebase:firebase-messaging:19.0.1' //17.4.0→19.0.1に変更 implementation 'com.google.firebase:firebase-core:17.0.1' //16.0.7→17.0.1に変更 ... }
以上、解決方法をご存知の方いらっしゃいましたらご教示いただければ幸いです。
よろしくお願いいたします。
回答1件
あなたの回答
tips
プレビュー