Build error android studio 3.1

问题: I'm experiencing error while loading fresh new template project after updating Android Studio to 3.1. Tried with and without this option, but no use: maven { url "h...

问题:

I'm experiencing error while loading fresh new template project after updating Android Studio to 3.1.

Tried with and without this option, but no use:

maven {
    url "https://maven.google.com"
}

during build, I'm seeing following messages:

Caused by: org.gradle.internal.resolve.ModuleVersionResolveException:
           Could not resolve com.android.tools.build:gradle:3.1.0.
<6 internal calls>
   ... 128 more
Caused by: org.gradle.api.resources.ResourceException:
           Could not get resource 'https://dl/google.com/dl/android/maven2/com/android/tools/build/gradle/3.1.0/gradle-3.1.0.pom' <21 internal calls>
   ... 133 more
Caused by: org.gradle.internal.resource.transport.http.HttpRequestException:
           Could not GET 'https://dl/google.com/dl/android/maven2/com/android/tools/build/gradle/3.1.0/gradle-3.1.0.pom'. <16 internal calls>
Caused by: org.apache.http.conn.HttpHostConnectException: Connect to dl.google.com:433 [dl.google.com/216.58.199.142] failed

build.gradle

apply plugin: 'com.android.application'

android {
  compileSdkVersion 27
  buildToolsVersion "27.0.3"
  defaultConfig {
    applicationId "com.example.am.myapplicationtest"
    minSdkVersion 19
    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'
    }
  }

Screenshots for reference: enter image description here

Gradle setting enter image description here


回答1:

Just add google() in your project level gradle file. It should look something like this:

buildscript {
    repositories {
        jcenter()
        google()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
    }
}
  • 发表于 2018-03-31 08:51
  • 阅读 ( 1022 )
  • 分类:sof

0 条评论

请先 登录 后评论
不写代码的码农
网文小编

0 篇文章

作家榜 »

  1. 网文小编 0 文章
返回顶部
部分文章转自于网络,若有侵权请联系我们删除