24

I just started learning and working with "Android Studio" software and editing a project. It took too long to figure out how to work with that. I just fixed many errors and now i know many thing about errors but one thing happened to me and it's making me crazy! I can't fix this error and don't know what is wrong with that. This is Error:

> Task :app:processReleaseResources FAILED
AGPBI: {"kind":"error","text":"Android resource linking failed","sources":[{"file":"C:\\Users\\****\\.gradle\\caches\\transforms-2\\files-2.1\\b635fd2d4b36b21da676271add72c19b\\material-1.4.0-alpha01\\res\\values\\values.xml"}],"original":"C:\\Users\\****\\.gradle\\caches\\transforms-2\\files-2.1\\b635fd2d4b36b21da676271add72c19b\\material-1.4.0-alpha01\\res\\values\\values.xml: AAPT: error: style attribute 'android:attr/contextPopupMenuStyle' not found.\n    ","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Android resource linking failed","sources":[{"file":"C:\\Users\\****\\.gradle\\caches\\transforms-2\\files-2.1\\b635fd2d4b36b21da676271add72c19b\\material-1.4.0-alpha01\\res\\values\\values.xml"}],"original":"C:\\Users\\****\\.gradle\\caches\\transforms-2\\files-2.1\\b635fd2d4b36b21da676271add72c19b\\material-1.4.0-alpha01\\res\\values\\values.xml: AAPT: error: style attribute 'android:attr/contextPopupMenuStyle' not found.\n    ","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Android resource linking failed","sources":[{"file":"C:\\Users\\****\\.gradle\\caches\\transforms-2\\files-2.1\\b635fd2d4b36b21da676271add72c19b\\material-1.4.0-alpha01\\res\\values\\values.xml"}],"original":"C:\\Users\\****\\.gradle\\caches\\transforms-2\\files-2.1\\b635fd2d4b36b21da676271add72c19b\\material-1.4.0-alpha01\\res\\values\\values.xml: AAPT: error: style attribute 'android:attr/contextPopupMenuStyle' not found.\n    ","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Android resource linking failed","sources":[{"file":"C:\\Users\\****\\.gradle\\caches\\transforms-2\\files-2.1\\b635fd2d4b36b21da676271add72c19b\\material-1.4.0-alpha01\\res\\values\\values.xml"}],"original":"C:\\Users\\****\\.gradle\\caches\\transforms-2\\files-2.1\\b635fd2d4b36b21da676271add72c19b\\material-1.4.0-alpha01\\res\\values\\values.xml: AAPT: error: style attribute 'android:attr/contextPopupMenuStyle' not found.\n    ","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Android resource linking failed","sources":[{"file":"C:\\Users\\****\\.gradle\\caches\\transforms-2\\files-2.1\\b635fd2d4b36b21da676271add72c19b\\material-1.4.0-alpha01\\res\\values\\values.xml"}],"original":"C:\\Users\\****\\.gradle\\caches\\transforms-2\\files-2.1\\b635fd2d4b36b21da676271add72c19b\\material-1.4.0-alpha01\\res\\values\\values.xml: AAPT: error: style attribute 'android:attr/dialogCornerRadius' not found.\n    ","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Android resource linking failed","sources":[{"file":"C:\\Users\\****\\.gradle\\caches\\transforms-2\\files-2.1\\b635fd2d4b36b21da676271add72c19b\\material-1.4.0-alpha01\\res\\values\\values.xml"}],"original":"C:\\Users\\****\\.gradle\\caches\\transforms-2\\files-2.1\\b635fd2d4b36b21da676271add72c19b\\material-1.4.0-alpha01\\res\\values\\values.xml: AAPT: error: style attribute 'android:attr/keyboardNavigationCluster' not found.\n    ","tool":"AAPT"}

Execution failed for task ':app:processReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > Android resource linking failed
     C:\Users\****\.gradle\caches\transforms-2\files-2.1\b635fd2d4b36b21da676271add72c19b\material-1.4.0-alpha01\res\values\values.xml: AAPT: error: style attribute 'android:attr/contextPopupMenuStyle' not found.

File which addressed in error text is out of my project folder and sure it is a Cached folder for gradle! Tried to clear caches, rebuilding project, deleting code lines from files, etc. nothing works! Hope someone can help me about this.

And my "build.gradle" file's codes is:

apply plugin: 'com.android.application'

android {

    compileSdkVersion 21
    buildToolsVersion '29.0.3'

    defaultConfig {
        applicationId "com.troup.platform"
        minSdkVersion 19
        targetSdkVersion 21
        versionCode 78
        versionName '5.7'
        multiDexEnabled true
        vectorDrawables.useSupportLibrary = true
    }

    dexOptions {

        jumboMode true
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    lintOptions {
        checkReleaseBuilds false
        // Or, if you prefer, you can continue to check for errors in release builds,
        // but continue the build even when errors are found:
        abortOnError false
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    productFlavors {
    }
    ndkVersion '22.0.7026061'
}

dependencies {
    implementation  fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.volley:volley:1.1.1'
    implementation 'com.github.chrisbanes.photoview:library:1.2.4'
    implementation 'com.facebook.android:facebook-android-sdk:5.15.3'
    implementation 'com.mikhaellopez:circularimageview:3.2.0'
    implementation 'com.squareup.okhttp:okhttp:2.7.5'
    implementation 'com.github.bumptech.glide:glide:4.12.0'
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'androidx.vectordrawable:vectordrawable-animated:1.1.0'
    implementation 'androidx.mediarouter:mediarouter:1.2.2'
    implementation 'androidx.browser:browser:1.3.0'
    implementation 'com.google.android.material:material:1.3.0'
    implementation 'androidx.recyclerview:recyclerview:1.1.0'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'com.balysv:material-ripple:1.0.2'
    implementation 'com.squareup.picasso:picasso:2.71828'
    implementation 'com.google.firebase:firebase-core:18.0.2'
    implementation 'com.google.firebase:firebase-ads:19.7.0'
    implementation 'com.google.firebase:firebase-messaging:21.0.1'
    implementation 'com.google.firebase:firebase-analytics:18.0.2'
    implementation 'com.google.android.gms:play-services-gcm:17.0.0'
    implementation 'com.google.android.gms:play-services-ads:19.7.0'
    implementation 'com.google.android.gms:play-services-location:18.0.0'
    implementation 'com.google.android.gms:play-services-auth:19.0.0'
    implementation 'com.android.billingclient:billing:3.0.2'
    implementation 'com.google.android.exoplayer:exoplayer:2.7.2'
    implementation 'androidx.multidex:multidex:2.0.1'
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'androidx.exifinterface:exifinterface:1.3.2'
    implementation "com.google.android.material:material:1.4.0-alpha01"

    implementation  files('libs/YouTubeAndroidPlayerApi.jar')
}
dependencies {
    implementation 'com.android.support:appcompat-v7:+'
}
apply plugin: 'com.google.gms.google-services'
  • OS: Windows 10
  • Android Studio Version: 4.1.2
Dr Mido
  • 2,414
  • 4
  • 32
  • 72
TLP Masih
  • 285
  • 1
  • 2
  • 9

11 Answers11

10

I faced a similar issue which I solved by downgrading the google services dependency.

My gradle had:

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.1"

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
}

dependencies {
    implementation 'com.google.android.material:material:1.5.0-rc01'
}

to

android {
        compileSdkVersion 26
        buildToolsVersion "26.0.1"
    
        defaultConfig {
            minSdkVersion 15
            targetSdkVersion 26
            versionCode 1
            versionName "1.0"
    }

dependencies {
    implementation 'com.google.android.material:material:1.2.0'
}

This resolved the issue for me. You could give it a try

Nickson
  • 101
  • 2
  • 4
4

The problem is here:

defaultConfig {
    targetSdkVersion 21
}

The attribute android.R.attr.contextPopupMenuStyle was not added until API level 24, so you must target at least 24 for the Material Components library to access that attribute.

Ben P.
  • 52,661
  • 6
  • 95
  • 123
  • oh yes it's works fine! But another error happened! `Execution failed for task ':app:processReleaseResources'. > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade > Android resource linking failed F:\Troup\MyNetwork\app\build\intermediates\packaged_manifests\release\AndroidManifest.xml:47: AAPT: error: attribute android:requestLegacyExternalStorage not found.` – TLP Masih Feb 28 '21 at 21:41
  • That one was added in API 29, so you must target 29 or higher. – Ben P. Feb 28 '21 at 22:12
  • Nice! it worked! BUT added new errors! about 100 errors look like: `F:\Troup\MyNetwork\app\src\main\java\ru\ifsoft\network\AccountSettingsActivity.java:6: error: cannot find symbol import androidx.core.app.Fragment; ^ symbol: class Fragment location: package androidx.core.app F:\Troup\MyNetwork\app\src\main\java\ru\ifsoft\network\AccountSettingsActivity.java:7: error: cannot find symbol import androidx.core.app.FragmentManager;` – TLP Masih Feb 28 '21 at 23:23
  • This might be a bit outdated for year 2021 and forward... – IgorGanapolsky Oct 07 '21 at 18:24
2

In my case, layout and drawable were missing. So, please check if any string, drawable, color or any drawable missed. enter image description here

enter image description here

Dharman
  • 30,962
  • 25
  • 85
  • 135
Komal
  • 328
  • 3
  • 15
2

I resolved the same issue by increasing the compileSdkVersion and targetSdkVersion both with same values

Zaman Rajpoot
  • 326
  • 2
  • 5
1

Looks like there is missing styles in your project. If there is another project you are studying and copying from, check its res/values/styles.xml file and compare with yours. Otherwise you need to create these styles.

Berkay Kireçci
  • 651
  • 5
  • 18
1

I was getting AAPT: error: resource android:attr/lStar not found on a fresh project using just the Empty Activity template, targeting a min SDK version of 21. To fix this issue, on the "Configure Your Project" step of creating a new project I had to check the box that says Use legacy android.support libraries in order to get the project to run. Apparently this prevents you from using the latest Play Services and Jetpack libraries, but that seems like an extremely minor concern.

Alternatively, these were the dependencies at fault so in build.gradle (app), I could downgrade to the legacy support libraries myself by replacing

dependencies {
    implementation 'androidx.appcompat:appcompat:1.4.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.3' 
}

with

dependencies {
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
}
James R
  • 11
  • 1
1

I was getting this error, even though, I removed my existing changes or change the branch to master.

The issue was happening because I have created a testing.xml which was not added or committed in git.

This testing.xml was having an error.

I removed that file and it solves the problem.

Surajkumar_cse
  • 165
  • 1
  • 11
1

This error seems to be mainly due to the difference in the compileSdkVersion and buildToolsVersion being used.

Even though I had installed the corrected buildTools (from SDK manager) , the Android Studio never knew about it, and it was picking the wrong buildToolsVersion.

Then I mentioned it in the android/build.gradle file under

ext attribute

buildscript {
    ext.kotlin_version = '1.5.0'
    repositories {
        google()
        mavenCentral()
    }

ext {
    buildToolsVersion = "31"
    minSdkVersion = 21
    compileSdkVersion = 31
    targetSdkVersion = 31
  }

dependencies {
    classpath 'com.android.tools.build:gradle:4.2.2'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    classpath 'com.google.gms:google-services:4.3.8'  // Google Services plugin
    classpath 'com.google.firebase:firebase-crashlytics-gradle:2.7.1'
    classpath 'com.google.firebase:perf-plugin:1.4.0'
  }
}

Then there were no such errors

Akshay Chopra
  • 1,035
  • 14
  • 10
1

I simply updated the version of material view in gradle.build and the error is gone.

implementation 'com.google.android.material:material:{add_latest_version_here}'

0

for me I use android material lib (com.google.android.material:material:1.x) and I wanted to test the app on Android api level 21 even that Im building on api 29

so I changed

android {
    compileSdkVersion 29
    defaultConfig {
        minSdkVersion 19
        targetSdkVersion 29

to

android {
    compileSdkVersion 21
    defaultConfig {
        minSdkVersion 19
        targetSdkVersion 21

that gave me same error you got,

That's was wrong because that lib ask to build the app on api 29 as stated on https://material.io/develop/android/docs/getting-started#2-compile-your-app-with-android-10

so I changed compileSdkVersion back to 29 and the problem disappeared and ran the app on API 21

Basheer AL-MOMANI
  • 14,473
  • 9
  • 96
  • 92
0

i have similler problem so i solved in this way:

first how this problem comes from

I am making splash screen in my project and make new splash.xml file according to instructor, them I want to splash screen inside main activity so I made new composable for main code another for splash screen and there comes one error that is in import section like theme splash link etc, so I removed this and run the program then I got the same error.

solution

so it comes form splash.xml so deleted this then solved

RusArtM
  • 1,116
  • 3
  • 15
  • 22