安卓工作室构建失败

3

我在从稳定渠道同步 Android Studio 4.1.2 的 Gradle 时,收到以下警告:

Failed to resolve: legacy-support-v4-1.0.0
Failed to resolve: asynclayoutinflater-1.0.0
Failed to resolve: media-1.0.0
Failed to resolve: swiperefreshlayout-1.0.0
Failed to resolve: slidingpanelayout-1.0.0
Failed to resolve: legacy-support-core-ui-1.0.0

以下是我的应用程序模块的build.gradle文件:

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

apply plugin: 'kotlin-kapt'

apply plugin: 'androidx.navigation.safeargs.kotlin'

androidExtensions {
    experimental = true
}

android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    defaultConfig {
        applicationId "com.sample.android.storytel"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0"
        buildConfigField "String", "STORYTEL_BASE_URL", "\"https://jsonplaceholder.typicode.com/\""
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    dataBinding {
        enabled = true
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    // Support libraries
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$version_kotlin"
    implementation "androidx.appcompat:appcompat:$version_support"
    implementation "com.google.android.material:material:$version_material"
    implementation "androidx.constraintlayout:constraintlayout:$version_constraint_layout"
    implementation "androidx.palette:palette-ktx:$version_palette"
    implementation "androidx.test.espresso:espresso-idling-resource:$version_espresso"

    // Android KTX
    implementation "androidx.core:core-ktx:$version_core"

    // Navigation
    implementation "androidx.navigation:navigation-fragment-ktx:$version_navigation"

    // Architecture components
    implementation "androidx.lifecycle:lifecycle-extensions:$version_lifecycle_extensions"

    // Retrofit
    implementation "com.squareup.retrofit2:retrofit:$version_retrofit"
    implementation "com.squareup.retrofit2:converter-moshi:$version_retrofit"
    implementation "com.squareup.retrofit2:adapter-rxjava2:$version_retrofit"

    // Dagger
    implementation "com.google.dagger:dagger:$version_dagger"
    kapt "com.google.dagger:dagger-compiler:$version_dagger"
    implementation "com.google.dagger:dagger-android:$version_dagger"
    implementation "com.google.dagger:dagger-android-support:$version_dagger"
    kapt "com.google.dagger:dagger-android-processor:$version_dagger"

    // Network
    implementation "com.squareup.okhttp3:logging-interceptor:$version_okhttp"
    implementation "com.squareup.picasso:picasso:$version_picasso"
    implementation "com.github.florent37:picassopalette:$version_picasso_palette"

    // Moshi for parsing the JSON format
    implementation "com.squareup.moshi:moshi:$version_moshi"
    implementation "com.squareup.moshi:moshi-kotlin:$version_moshi"

    //Android RX
    implementation "io.reactivex.rxjava2:rxjava:$version_rxjava"
    implementation "io.reactivex.rxjava2:rxandroid:$version_rxandroid"

    // Timber
    implementation "com.jakewharton.timber:timber:$version_timber"

    // Dependencies for local unit tests
    testImplementation "org.mockito:mockito-core:$version_mockito"

    // Dependencies for Instrumentation tests
    androidTestImplementation "androidx.test.ext:junit:$version_junit_ext"

    // Espresso UI Testing
    androidTestImplementation "androidx.test.espresso:espresso-core:$version_espresso"
    androidTestImplementation "androidx.test.espresso:espresso-contrib:$version_espresso"

    // Testing Architecture components
    testImplementation "androidx.arch.core:core-testing:$version_lifecycle_test"

    // Android Testing Support Library's runner and rules
    androidTestImplementation "androidx.test:runner:$version_runner"
    androidTestImplementation  "androidx.test:rules:$version_rules"

    // AndroidX Test - JVM testing
    testImplementation "androidx.fragment:fragment-testing:$version_fragment"
}

当我构建项目时,收到以下错误信息:
Could not resolve asynclayoutinflater-1.0.0.aar (androidx.asynclayoutinflater:asynclayoutinflater:1.0.0)

在这里您可以找到我的项目:https://github.com/Ali-Rezaei/Colors

你知道为什么会发生这种情况并如何解决吗?

补充说明:我意识到这与以下依赖项有关:

implementation "com.github.florent37:picassopalette:$version_picasso_palette"

没有这个依赖项,它的功能就如预期一样。

我已经下载了你的项目,IDE可以下载你上面提到的依赖项。你可以尝试使用VPN,因为如果你使用伊朗IP,可能会出现403或其他错误。 - ʍѳђઽ૯ท
谢谢@Mohsen,我感觉我理解了,所以我正在使用VPN,但它仍然无法下载依赖项。 - Ali
毫无疑问,您对这些限制和制裁相关的事情有很好的理解,但我想问题可能来自于您的VPN。尝试更改位置并使用“文件->使缓存失效-重启”如何? - ʍѳђઽ૯ท
再次感谢,是的可能与我的 VPN 有关。 - Ali
@ʍѳђઽ૯ท,我意识到这与picassopalette有关。你可以在我的问题末尾检查它。你能再试一次吗?你能构建这个项目吗?我创建了一个空的新应用程序并添加了这个依赖项,但是我收到了同样的警告和错误。 - Ali
刚刚检查了一下这个库,似乎它正在使用旧的支持库。所以,正如“Rahat”所说,你需要注意这个库(无论是更新它还是使用另一个库),因为你在项目中使用了AndroidX依赖和实现。此外,请确保在你的gradle-wrapper.properties中使用最新的包装器:distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.1-all.zip。(有时这真的很有帮助) - ʍѳђઽ૯ท
3个回答

1
你生活在一个受制裁的国家,你必须使用翻墙软件。你可以使用this

1
谢谢@Pouria,我感觉我理解了,但是我已经使用了VPN,而且我也尝试了你的建议,但是没有起作用。对于你的VPN建议点赞。 - Ali

1
问题在于implementation "com.github.florent37:picassopalette:$version_picasso_palette"这个库使用了Android的支持库依赖,而你正在尝试在使用Jetpack库的项目中使用它
你可以通过以下方式解决:
  1. 使用已迁移到JetPack的该库的版本
或者

你可以下载该库的zip文件并将其提取出来,然后作为一个项目打开,并从重构菜单迁移到AndroidX,然后将该自定义项目作为库导入到你的项目中。


似乎没有将库迁移到JetPack的版本可用。因此,您的后续解决方案可能是一种变通方法。 - Ali

0
Could not resolve asynclayoutinflater-1.0.0.aar (androidx.asynclayoutinflater:asynclayoutinflater:1.0.0)

这意味着Gradle无法在任何地方找到该依赖项。请确保库可以被Gradle访问以解决问题。

基本上,Gradle将您的依赖项视为一些无法解决的胡言乱语。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接