gpt4 book ai didi

android - 错误 : Failed to resolve: androidx. 生命周期 :lifecycle:2. 2.0-beta01

转载 作者:行者123 更新时间:2023-12-04 13:17:51 25 4
gpt4 key购买 nike

我遇到了 build.gradle 的问题文件,特别是模块 'android.x.lifecycle' .

我有以下错误

ERROR: Failed to resolve: androidx.lifecycle:lifecycle:2.2.0-beta01
This is the last version of androidx.lifecycle

不知道是不是语法错误

这是 build.gradle 文件
    apply plugin: 'com.android.application'

android {
compileSdkVersion 29
defaultConfig {
applicationId "com.flixarts.ar.englishnow"
minSdkVersion 14
targetSdkVersion 29
buildToolsVersion '25.0.2'
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
buildToolsVersion = '28.0.3'
}

dependencies {
implementation 'androidx.lifecycle:lifecycle:2.2.0-beta01'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'com.google.android.material:material:1.1.0-beta01'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.gms:play-services-ads:18.2.0'
implementation 'com.android.support:multidex:1.0.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'androidx.cardview:cardview:1.0.0'
}

最佳答案

更改此行:

androidx.lifecycle:lifecycle:2.2.0-beta01

使用其中之一:
implementation "androidx.lifecycle:lifecycle-extensions:2.2.0-beta01"
implementation "androidx.lifecycle:lifecycle-viewmodel:2.2.0-beta01"
implementation "androidx.lifecycle:lifecycle-livedata:2.2.0-beta01"
implementation "androidx.lifecycle:lifecycle-livedata-core:2.2.0-beta01"
implementation "androidx.lifecycle:lifecycle-runtime:2.2.0-beta01"

有关生命周期的更多信息 here .

还:
  • 更改 com.android.support:multidex:1.0.3androidx.multidex:multidex:2.0.1因为您使用的是 androidx 库
  • 您正在添加 implementation 'androidx.appcompat:appcompat:1.1.0'三次
  • 删除支持库:implementation 'com.android.support.constraint:constraint-layout:1.1.3'
  • 删除 buildToolsVersion '25.0.2'buildToolsVersion = '28.0.3' (在任何情况下都不要使用 =)。您可以指定buildToolsVersion "29.0.2"android阻止或忽略它,gradle 将根据 targetSdkVersion 自动使用最新版本指定
  • 关于android - 错误 : Failed to resolve: androidx. 生命周期 :lifecycle:2. 2.0-beta01,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58381391/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com