2

so my project was working fine yesterday and I tried to open it today and it gives me that error , help would be much appreciated I tried to search for a long time about whats going wrong but it seems all answers not working with me

Error:Failed to resolve: runtime Open File

here is build.gradle(Project) 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.0.1'
        classpath 'com.google.gms:google-services:3.2.0'


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

allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com" // Google's Maven repository
        }
    }
}

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

and here is build app profile

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.example.android.writer"
        minSdkVersion 15
        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 {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    implementation 'com.google.firebase:firebase-database:11.0.4'
    implementation 'com.google.firebase:firebase-auth:11.0.4'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    implementation 'com.rengwuxian.materialedittext:library:2.1.4'
    implementation 'com.android.support:design:26.1.0'
    implementation 'com.github.clans:fab:1.6.4'
    implementation 'com.android.support:cardview-v7:26.1.0'
    implementation 'com.firebase:firebase-client-android:2.5.2+'
}


apply plugin: 'com.google.gms.google-services'
Gina Habib
  • 21
  • 1
  • 5

4 Answers4

16

Based on the answer in Android Studio 3.1.2 : Failed to resolve: runtime, try changing the order of imports in build.gradle project file as

allprojects {
    repositories {
        google()
        maven {
            url "https://maven.google.com" // Google's Maven repository
        }
        jcenter()

    }
}

This worked for me.

Tamilarasu
  • 341
  • 2
  • 7
  • 1
    I encountered this problem as well with a gradle file of a submodule, and this answer worked. For me, Android Studio said "Failed to resolve: common" as well as "Failed to resolve: runtime" – jiroch Jun 11 '18 at 15:28
1
allprojects {
    repositories {
        google()
        maven {
            url "https://maven.google.com" // Google's Maven repository
        }
        jcenter()

    }
}

You must place google() as the 1st line. Reminder First line. I hope it will help you.

anothernode
  • 5,100
  • 13
  • 43
  • 62
bb14816
  • 473
  • 1
  • 5
  • 14
1

This is very weird and took me almost 4-5 hours to fix. But, it turns out you need to put google() at the top and jcenter() at the bottom of repositories in build files for all modules. Maven can go in between and it'll be fixed.

Makyen
  • 31,849
  • 12
  • 86
  • 121
Ritik Rishu
  • 159
  • 2
  • 4
1

This worked for me

repositories {
    google()`Goolge repo`
    jcenter()
    maven {
        url 'https://maven.google.com/ `Google maven repo`
        name 'Google'
    }

}
eisbehr
  • 12,243
  • 7
  • 38
  • 63
tarun_sharma
  • 139
  • 1
  • 5