Android 工作室构建失败
Android studio build fails
当我从稳定频道在 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"
没有这个依赖项,它会按预期工作。
Could not resolve asynclayoutinflater-1.0.0.aar (androidx.asynclayoutinflater:asynclayoutinflater:1.0.0)
这意味着 gradle 无法在任何地方找到该依赖项。确保库可以被 gradle 访问以解决问题。
基本上 gradle 将您的依赖视为一些无法解决的胡言乱语。
您生活在一个受到制裁的国家。您必须使用过滤器断路器。
你可以使用this
这里的问题是
implementation "com.github.florent37:picassopalette:$version_picasso_palette"
这个库是 它使用 android 的支持库依赖项,而你 试图在你使用 jetpack 库的项目中使用它.
您可以通过
解决
- 使用迁移到 JetPack 的库版本。。
或
您可以下载该库的 zip 并将其解压缩,然后将其作为项目打开,然后从重构菜单迁移到 AndroidX
然后将该自定义项目作为库导入你的项目。
当我从稳定频道在 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"
没有这个依赖项,它会按预期工作。
Could not resolve asynclayoutinflater-1.0.0.aar (androidx.asynclayoutinflater:asynclayoutinflater:1.0.0)
这意味着 gradle 无法在任何地方找到该依赖项。确保库可以被 gradle 访问以解决问题。
基本上 gradle 将您的依赖视为一些无法解决的胡言乱语。
您生活在一个受到制裁的国家。您必须使用过滤器断路器。
你可以使用this
这里的问题是
implementation "com.github.florent37:picassopalette:$version_picasso_palette"
这个库是 它使用 android 的支持库依赖项,而你 试图在你使用 jetpack 库的项目中使用它.
您可以通过
解决- 使用迁移到 JetPack 的库版本。。
或
您可以下载该库的 zip 并将其解压缩,然后将其作为项目打开,然后从重构菜单迁移到 AndroidX
然后将该自定义项目作为库导入你的项目。