Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error:Failed to resolve: common in android studio

I have reinstalled the android studio, and while opening my old project again it shows below error:

Error:Failed to resolve: firebase-messaging
<a href="openFile:D:/Android projects/Porject_name/app/build.gradle">Open File</a>

Error:Failed to resolve: common
<a href="openFile:D:/Android projects/Porject_name/app/build.gradle">Open File</a>

build.gradle(Porject) file:

// Top-level build file where you can add configuration options common to 

all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.3'
        classpath 'com.google.gms:google-services:3.1.0'

    }
}

allprojects {
    repositories {
        jcenter()
        mavenCentral()

        google()


        maven {
            url "https://jitpack.io"
        }

    }
}

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

build.gradle(app) file:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion '27.0.3'
    useLibrary 'org.apache.http.legacy'

    defaultConfig {
        applicationId "com.example.abc"
        minSdkVersion 16
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:26.1.0'
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:design:26.1.0'
    compile 'com.android.support:support-v4:26.1.0'
    compile 'com.github.traex.rippleeffect:library:1.3'
    compile 'com.mcxiaoke.volley:library-aar:1.0.0'
    compile 'com.google.firebase:firebase-messaging:12.0.0'
    compile 'com.baoyz.swipemenulistview:library:1.3.0'
    compile 'se.emilsjolander:stickylistheaders:2.1.5'
    compile 'com.applandeo:material-calendar-view:1.4.0'
    compile 'com.github.michaelye.easydialog:easydialog:1.4'
    implementation 'de.hdodenhof:circleimageview:2.2.0'
    compile 'com.squareup.picasso:picasso:2.5.2'

}
apply plugin: 'com.google.gms.google-services'

I have added all the required plugins and sdk but still it won't work. Installed Firebase plugins.even google play services as well. It was working fine before I uninstalled studio. Please help.

like image 333
Shuchi Sheth Avatar asked Jun 08 '18 12:06

Shuchi Sheth


2 Answers

Add/Move this maven {url "https://maven.google.com"} to the top made mine work in build.gradle

like image 103
Sujeet Kumar Mehta Avatar answered Oct 24 '22 06:10

Sujeet Kumar Mehta


This works for me. I just reorder them as like this

repositories {
    mavenCentral()
    mavenLocal()
    google()
    jcenter()
  }
like image 28
Istiyak Avatar answered Oct 24 '22 06:10

Istiyak