【问题标题】:Error:Failed to resolve: runtime错误:无法解决:运行时
【发布时间】:2018-06-10 22:37:35
【问题描述】:

所以我的项目昨天运行良好,我今天尝试打开它,它给了我这个错误,非常感谢帮助 我试图搜索很长一段时间出了什么问题,但似乎所有答案都不适用于我

错误:无法解决:运行时 打开文件

这里是 build.gradle(Project) 文件:

   // 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
}

这里是构建应用配置文件

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'

【问题讨论】:

    标签: android-studio


    【解决方案1】:

    根据Android Studio 3.1.2 : Failed to resolve: runtime中的答案,尝试将build.gradle项目文件中的导入顺序更改为

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

    这对我有用。

    【讨论】:

    • 我在子模块的 gradle 文件中也遇到了这个问题,这个答案很有效。对我来说,Android Studio 说“无法解析:常见”以及“无法解析:运行时”
    【解决方案2】:

    这很奇怪,我花了将近 4-5 个小时来修复。但是,您需要在所有模块的构建文件中将google() 放在顶部,将jcenter() 放在存储库的底部。 Maven 可以介于两者之间,它会被修复。

    【讨论】:

      【解决方案3】:
      allprojects {
          repositories {
              google()
              maven {
                  url "https://maven.google.com" // Google's Maven repository
              }
              jcenter()
      
          }
      }
      

      您必须将google() 作为第一行。提醒第一行。希望对你有帮助。

      【讨论】:

        【解决方案4】:

        这对我有用

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

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2012-10-27
          • 2020-07-19
          • 1970-01-01
          • 2016-12-05
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多