0

Recently I got this error when I build my app. I did not modify anything from my last successful build.

here is the error that I got

Android resource linking failed

C:\Users\Asus\.gradle\caches\transforms-3\d7936c72110369b4f70374bb97b71a45\transformed\com.google.android.gms.base\drawable-hdpi-v4_common_full_open_on_phone.png.flat: error: failed to read file: magic value is 0x929c1a24 but AAPT expects 0x54504141.

error: failed parsing overlays.

Here is my 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"
}

Can someone help me?

I have cleaned and rebuild my app, I have restarted my Android Studio, I also updated to the last version of IDE but nothing seem to work.

1 Answers1

0

If you have recently changed your namespace 'com.yourcompany.yourappname' and your current import to your resources 'com.yourcompany.your_app_name.R' doesn't match, it would also cause this error.

Make sure your namespace matches your imports

  • in build.gradle(Module:app) namespace 'com.yourcompany.yourappname'

  • in your java files: import com.yourcompany.yourappname.R

Allen
  • 301
  • 2
  • 4