Android资源链接失败,错误:解析覆盖Android失败



最近我在构建应用程序时遇到了这个错误。我没有修改上一次成功构建的任何内容。

这是我得到的错误

Android资源链接失败

C: \Users\Asus\.gradle\caches\transforms-3\d7936c72110369b4f70374bb97b71a45\transformed\com.google.android.gms.base\drawable-hdpi-v4_common_full_open_on_phone.png.flat:错误:无法读取文件:magic值为0x929c1a24,但AAPT预期为0x54504141。

错误:分析覆盖层失败。

这是我的build.gradle

plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin'
id 'kotlin-parcelize'
}
android {
namespace 'com.example.amiconnew'
compileSdk 33
defaultConfig {
applicationId "com.example.amiconnew"
minSdk 21
targetSdk 33
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.5.1'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.navigation:navigation-fragment-ktx:2.5.2'
implementation 'androidx.navigation:navigation-ui-ktx:2.5.2'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
/*CUSTOM LIBRARY*/
// MAPS
implementation 'com.google.android.gms:play-services-maps:18.1.0'
implementation "com.google.android.gms:play-services-location:20.0.0"
implementation 'com.google.maps.android:android-maps-utils:2.3.0'
//LIVE DATA
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1"
implementation "androidx.activity:activity-ktx:1.6.0"
//LIFECYCLE SCOPES LIBRARY
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1'
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.5.1"
implementation 'androidx.datastore:datastore-preferences:1.0.0'
// RETROFIT
implementation "com.squareup.retrofit2:retrofit:2.9.0"
implementation "com.squareup.retrofit2:converter-gson:2.9.0"
implementation "com.squareup.okhttp3:logging-interceptor:4.9.0"
// MATERIAL DESIGN
implementation "com.google.android.material:material:1.8.0-alpha01"
//NAVIGATION
implementation 'androidx.navigation:navigation-fragment-ktx:2.5.3'
implementation 'androidx.navigation:navigation-ui-ktx:2.5.3'
//SWIPE REFRESH LAYOUT
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
}

有人能帮我吗?

我已经清理并重建了我的应用程序,我重新启动了我的Android Studio,我也更新到了IDE的最后一个版本,但似乎什么都不起作用。

如果您最近更改了命名空间"com.yourcompany.yourappname",并且当前导入到资源"com.yourcompany.your_app_name.R"不匹配,也会导致此错误。

确保你的命名空间匹配你的导入

build.gradle中的
  • (模块:app)命名空间"com.yourcompany.yourappname">

  • 在您的java文件中:导入com.yourcompany.yourappname.R

最新更新