【问题标题】:Android gradle failed to resolve core right after creating a androidx projectAndroid gradle 在创建 androidx 项目后无法立即解析核心
【发布时间】:2019-07-01 16:04:21
【问题描述】:

我正在 android studio 3.3 中使用 androidx 创建一个新的 android 项目,并且在项目创建后立即出现以下错误

ERROR: Failed to resolve: core
Affected Modules: app


ERROR: Failed to resolve: collection
Affected Modules: app


ERROR: Failed to resolve: annotation
Affected Modules: app


ERROR: Failed to resolve: lifecycle-common
Affected Modules: app


ERROR: Failed to resolve: core-common
Affected Modules: app

我已经下载了最新的 google 支持存储库、gradle 4.10.1、gradle android tools 3.3.0,我还检查了我对 maven.google.com 和 jcenter.bintary.com 的访问权限,这很好。

我也清理了项目并重新启动了 android studio,但它们都没有工作

我的依赖:

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.0-beta01'
implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'

以及所有项目存储库:

google()
jcenter()
maven { url "https://jitpack.io" }
mavenCentral()

不幸的是,错误不清楚,我不知道这是怎么回事,谢谢你的帮助

【问题讨论】:

    标签: java android android-studio gradle androidx


    【解决方案1】:

    Bug是因为android studio默认的androidx依赖版本,我把依赖改成:

    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation 'androidx.appcompat:appcompat:1.0.0'
        implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
        androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
    }
    

    它现在工作正常。我从here得到这些版本

    【讨论】:

      【解决方案2】:

      我建议你改变这些

      你用它

      implementation 'androidx.appcompat:appcompat:1.0.0'
      

      改成

        implementation 'androidx.appcompat:appcompat:1.+'
      

      androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
      

      改成

          androidTestImplementation 'androidx.test:runner:1.+'
      

      【讨论】:

        【解决方案3】:

        我在我的 gradle 中更新了这 3 行

        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'androidx.test.ext:junit:1.1.1'
        androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2013-06-10
          • 1970-01-01
          • 1970-01-01
          • 2017-04-03
          • 1970-01-01
          • 2012-12-04
          • 1970-01-01
          • 2017-12-03
          相关资源
          最近更新 更多