morex
morex

Reputation: 99

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 "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

Upvotes: 3

Views: 7339

Answers (2)

Hardik Trivedi
Hardik Trivedi

Reputation: 693

This kind of issues are arising due to many reasons, but in those causes, the most important cause would be lack of JDK and JRE in your system. Check whether you have installed Java Runtime and JDK properly or not. Try running the command in terminal : ~> javac And if this command gives you error like Command not found. Then install JRE from Java Downloads and build your project again.

Upvotes: 0

Joshua
Joshua

Reputation: 356

This is a network issue

I think your problem is caused by bad network, since:

Caused by: org.apache.http.conn.HttpHostConnectException:
Connect to dl.google.com:433 [dl.google.com/216.58.199.142] failed

I face a similar problem, and at last I found the root cause is the default proxy of gradle(NOT for Android Studio but for gradle!)

I defined my own proxy settings in gradle.properties, but when I click sync in Android Studio, my settings does not apply and result in a error like this:

Error:Failed to resolve: com.android.support:appcompat-v7:27.0.1
Install Repository and sync project
Open File
Show in Project Structure dialog

Solution

At last I solved my problem by build my application by command line and set proxy myself, like this:

gradlew -Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=3128 -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=3129

Get this from Gradle proxy configuration, Thanks to Guillaume Berche.

Upvotes: 5

Related Questions