嘿,我正在尝试运行我的应用程序,我得到这个错误
构建.gradle
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
}
android {
compileSdk 30
configurations.all {
resolutionStrategy { force 'androidx.core:core-ktx:1.7.0-alpha01' }
}
defaultConfig {
applicationId "com.example.listadapter"
minSdk 21
targetSdk 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
viewBinding true
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation "com.squareup.retrofit2:converter-moshi:2.5.0"
implementation 'com.squareup.okhttp3:logging-interceptor:4.9.1'
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation "com.squareup.moshi:moshi:1.12.0"
implementation "com.squareup.moshi:moshi-kotlin:1.12.0"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.0"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.0"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.4.0"
implementation "android.arch.lifecycle:extensions:1.1.1"
implementation 'androidx.fragment:fragment-ktx:1.3.6'
}
我从这个link尝试了这个All Example,它不工作
安装应用程序后出错。我刚创建了一个新的应用程序。我不明白为什么会这样。有人知道如何解决这个问题吗?谢谢。
One or more issues found when checking AAR metadata values:
The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.0.
AAR metadata file: /Users/vmodi/.gradle/caches/transforms-3/b7f9608e476cb2e496993f185af8912c/transformed/jetified-lifecycle-viewmodel-ktx-2.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.
The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.lifecycle:lifecycle-runtime-ktx:2.4.0.
AAR metadata file: /Users/vmodi/.gradle/caches/transforms-3/538fea46e89a6c8a3e3eec533224abb8/transformed/jetified-lifecycle-runtime-ktx-2.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.
The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.lifecycle:lifecycle-livedata-ktx:2.4.0.
AAR metadata file: /Users/vmodi/.gradle/caches/transforms-3/6a1f77e99280b09902894e4ae8301047/transformed/jetified-lifecycle-livedata-ktx-2.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.
The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.lifecycle:lifecycle-viewmodel:2.4.0.
AAR metadata file: /Users/vmodi/.gradle/caches/transforms-3/41cf6125c3fd7a33d28222cf07d20520/transformed/lifecycle-viewmodel-2.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.
The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.lifecycle:lifecycle-runtime:2.4.0.
AAR metadata file: /Users/vmodi/.gradle/caches/transforms-3/655163560a267a5b16e2f66044d78641/transformed/lifecycle-runtime-2.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.
The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.lifecycle:lifecycle-livedata:2.4.0.
AAR metadata file: /Users/vmodi/.gradle/caches/transforms-3/1ca84d966e72f2f06b580da1765a55a5/transformed/lifecycle-livedata-2.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.
The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.lifecycle:lifecycle-livedata-core-ktx:2.4.0.
AAR metadata file: /Users/vmodi/.gradle/caches/transforms-3/3ed4d52253be7f6d85cbabee72c886d3/transformed/jetified-lifecycle-livedata-core-ktx-2.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.
The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.lifecycle:lifecycle-livedata-core:2.4.0.
AAR metadata file: /Users/vmodi/.gradle/caches/transforms-3/4e8a32482e233cfbbc450e03aabed8dd/transformed/lifecycle-livedata-core-2.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.
如果我改变我的compileSdk 31
,它会给我另一个错误。
Could not resolve all files for configuration ':app:androidApis'.
Failed to transform android.jar to match attributes {artifactType=android-mockable-jar, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime, returnDefaultValues=false}.
Execution failed for MockableJarTransform: /Users/vmodi/Library/Android/sdk/platforms/android-31/android.jar.
Cannot create mockable android.jar
/Users/vmodi/Library/Android/sdk/platforms/android-31/android.jar
9条答案
按热度按时间x8goxv8g1#
将
compileSdk 30
更改为31。对我很有效!
erhoui1w2#
改变你的
compileSdk 30 to 31
。就这样。享受你的编码...
axr492tv3#
在新版本的应用程序中:只需将compileSdk从32更改为33.
nnt7mjpx4#
compileSdk和targetSdk都应该是31。您尝试过吗?
km0tfn4u5#
依赖项:androidx.生命周期:lifecycle-runtime-ktx:2.4.0.问题是这个依赖项,可能有一些可传递的依赖项错误.我建议使用这个依赖项的alpha版本,为我工作.替换为这个依赖项:androidx.生命周期:生命周期-*:2.4.0-alpha 03
mbzjlibv6#
这是因为你刚刚升级了Kotlin。
打开SDK管理器,安装Android 12(API 31)或更高版本,然后将compileSdkVersion更改为31(或更高版本),并将targetSdkVersion更改为31(或更高版本)。
然后,您还需要将minSdkVersion更改为19。
yftpprvb7#
对于我来说,将这两个值设置为API 31是有效的
o2g1uqev8#
如果有人仍然遇到这个错误,请将他们的compileSdk更改为33。
fv2wmkja9#
其实我遇到了一个问题:每次我运行应用程序时,AAR元数据都会给予错误,因此我这样做了,它工作正常。转到屏幕左侧,有一个名为“Gradle Scripts“的选项,单击它,将有许多选项,因此单击第二个名为“build.gradle module”的选项,单击它,转到名为“dependencies”的最后一个方法,在该方法中有一行:实现'androidx.appcompat:appcompat:1.5.1',因此删除“:1.5.1“,使该行变为:实现'androidx.appcompat:appcompat',它对我有用,我希望它也能对你有用