-1

I was trying to add firebase auth to my android project but getting this error. I have tried adding 'com.google.firebase:firebase-core:16.0.3' too but its taking more than 40 mins and still not syncing the gradle.

This is build.gradle file:

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "myaid.startup"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.google.firebase:firebase-auth:16.0.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'
}

This is app.gradle file:

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

buildscript {
    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.2'
        classpath 'com.google.gms:google-services:4.1.0'

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

allprojects {
    repositories {
        google()
        jcenter()

    }
}

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

This is the error:

FAILURE: Build failed with an exception.

CONFIGURE FAILED in 2m 13s ERROR: Connection reset

  • network issue, please check your network – Basi Mar 19 '19 at 11:40
  • Please read [Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers?](//meta.stackoverflow.com/q/326569). – Zoe Mar 19 '19 at 11:43
  • 1
    Please don't tag questions with the android-studio tag just because you use it: the Android Studio tag should **only** be used when you have questions about the IDE itself, and not any code you write (or want to write) in it. See [when is it appropriate to remove an IDE tag](https://meta.stackoverflow.com/a/315196/6296561), [How do I avoid misusing tags?](https://meta.stackoverflow.com/questions/354427/how-do-i-avoid-misusing-tags), and [the tagging guide](/help/tagging). Please use [android] or other relevant tags instead. Also, you need to create a [mcve] - and do not add screenshots of code – Zoe Mar 19 '19 at 11:44
  • @Basi I have set -the HTTP Proxy as no proxy and my rest of the things are working, I'm posting this question on the same network. Can you please suggest me something else because I don't think its the network problem. – Abhinay Shrivastav Mar 19 '19 at 11:45
  • @AbhinayShrivastav please remove the images and paste both gradle – Basi Mar 19 '19 at 11:51
  • @Basi done the editing, please help. – Abhinay Shrivastav Mar 19 '19 at 12:08
  • @AbhinayShrivastav try to restart android studio – Basi Mar 19 '19 at 12:23
  • @Basi I have tried uninstalling it and installed it again still getting this error. Do you think this is something version related problem? – Abhinay Shrivastav Mar 19 '19 at 12:24
  • Please check are you using offline work? – Faysal Ahmed Mar 19 '19 at 12:30
  • @FaysalAhmed I have uninstalled the android studio 3.3.2 and installed 3.1.0, and now getting " Download https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.1.2/gradle-3.1.2.pom 1m 1s 39ms " AND " Download https://jcenter.bintray.com/com/android/tools/build/gradle/3.1.2/gradle-3.1.2.pom 1m 0s 755ms " as new error. – Abhinay Shrivastav Mar 19 '19 at 13:06
  • @FaysalAhmed After going to the links some gradle-3.1.2.pom is downloaded but I don't know where to add it? Can you look into this link and help me if you understand anything. https://stackoverflow.com/questions/51797446/android-studio-3-1-4-gradle-sync-failed I am from INDIA. – Abhinay Shrivastav Mar 19 '19 at 13:07
  • try [this](https://stackoverflow.com/a/30450020/4649110) then resync – Basi Mar 19 '19 at 13:09
  • @AbhinayShrivastav which version of gradle wrapper you have currently used. For checking this check gradle-wrapper.properties file. – Faysal Ahmed Mar 19 '19 at 14:52
  • @FaysalAhmed with 3.3.0 I'm using 4.10 and with 3.1.0 i'm using 4.4 – Abhinay Shrivastav Mar 19 '19 at 16:33
  • For 3.3.0 use wrapper version 4.10.1 instead of 4.10. – Faysal Ahmed Mar 19 '19 at 16:45

2 Answers2

0

I have resolved this problem by removing all my .gradle files, SDK files, .m2 files, .androidstudio files and then re-installing it.

Followed this answer: How to completely uninstall Android Studio

0

Please check your gradle's proxy settings. Enable it or disable it in the following file:

~/.gradle/gradle.properties

Like:

systemProp.https.proxyPort=1080
systemProp.http.proxyHost=127.0.0.1
systemProp.https.proxyHost=127.0.0.1
systemProp.http.proxyPort=1080

Advices:

  1. If your connection to repositories is not stable, use a proxy instead of direct connection.
  2. If you used to use a proxy for gradle, check if it is still working.
ShinChven
  • 473
  • 5
  • 11
  • I'm not sure why the settings in my `gradle.properties` file are different from those in Android Studio preferences. Can I safely remove the file so that I connects directly? – rraallvv Jul 27 '19 at 10:40
  • @rraallvv sure, you can remove the proxy settings. Those are unnecessary settings in normal condition. – ShinChven Jul 29 '19 at 01:32