java - Android gradle 在创建 androidx 项目后无法立即解析核心

标签 java android android-studio gradle androidx

我正在 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

我已经下载了最新的谷歌支持存储库,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()

不幸的是,错误不明确,我不知道这是怎么回事,感谢您的帮助

最佳答案

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 得到这些版本

关于java - Android gradle 在创建 androidx 项目后无法立即解析核心,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54575030/

相关文章:

android - 我的应用程序只是构建并且从未在实际设备上安装 apk(Android Studio)

android - ListView 工具 :listitem not working in android studio 2. 2 稳定 channel

android - 找不到选项来禁用离线gradle

java - 我如何监控 Java 中的 XML 解析(使用 JDOM)?

java - 如何计算列表中自定义数据类型的值?

android - Android Studio中的Gradle构建出错

java - 如何在 Android 上使用 HTTPS 对服务器进行 POST 调用

java - 序列化性能和 Google Android

java - 将 JPanel 保存为图像(对象)并将其绘制回 JPanel

android - 检查小部件是否放置在 Android 屏幕上