A Flutter Android app I developed suddenly compiled wrong today.
Error:
What went wrong:
Execution failed for task ':app:processDebugResources'.
Android resource linking failed
/Users/xxx/.gradle/caches/transforms-2/files-2.1/5d04bb4852dc27334fe36f129faf6500/res/values/values.xml:115:5-162:25: AAPT: error: resource android:attr/lStar not found.
error: failed linking references.
I tried
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
The build failed in 16 seconds.
Using the answer from here
Update compileSdkVersion and targetSdkVersion to 31
And add this code snippet in your android/build.gradle file at the very end.
configurations.all {
resolutionStrategy {
force 'androidx.core:core-ktx:1.6.0'
}
}
Just recently the original author of audioplayers package fixed this issue in his recent PR. It has been fixed in audioplayers version 0.20.1, so if your issue is related to audioplayers, do upgrade.
For those who have this issue in a Cordova application context like me and using an Android API version older than 31 (29 in my case), I found a clean way to bypass it.
TL;DR
If you are using the plugin cordova.plugins.diagnostic, uninstall it first then reinstall it using the following argument:
cordova plugin add cordova.plugins.diagnostic --variable ANDROIDX_VERSION=1.0.0
Refresh the whole android platform and you're project should not be using the androidx.core:core:1.7.0-beta02 anymore.
Full explaination
Solutions already mentionned in the thread (gradle rules to force a certain version of a package) will not work with Cordova as it handles the whole gradle process on it's own (gathering plugins dependencies, config.xml settings and processing everything) and it's really difficult to override specific things.
I did not manage to fix our problem using resolutionStrategy for example.
And migrating to Android API 31 isn't always an easy solution (plugins & dependencies need to support it in particular)
Instead, I tried to find which of my installed plugins were having a dependency linked to the androidx.core:core package, which breaks everything in its 1.7.0-beta02 version.
No one in my list was directly using it, but I found (with the help of the builded build.gradle) that the following package androidx.appcompat:appcompat was used and since it's related to AndroidX as well, I digged a bit and I quickly found-out that the version used for it was 1.+ (latest 1.xx).
Checking on mavenrepo, androidx.appcompat:appcompat has our buggy package androidx.core:core as dependency (1.7.0-beta02 on the latest).
After a quick search with my IDE, I found the definition of the dependency :
<framework src="androidx.appcompat:appcompat:$ANDROIDX_VERSION" />
It was used by a plugin named cordova-diagnostic-plugin. (Pretty common in a Cordova project, it basically handles Android settings, permissions and hardware stuff)
I noticed that an environment variable was used to define the package version (and set by default to 1.+).
Going on the plugin's GitHub documentation : https://github.com/dpa99c/cordova-diagnostic-plugin#androidx-library will tell you that you can indeed set a custom version when installing the plugin with the Cordova command.
Which I did (I removed the plugin first):
cordova plugin add cordova.plugins.diagnostic --variable ANDROIDX_VERSION=1.0.0
After rebuilding the android platform, I started a new build and it was finally successful !
androidx.appcompat:appcompat:1.0.0 was used as well as the androidx.core:core package in its 1.0.0 version. No more error: resource android attr/lStar not found issue !
To sum-up : check your plugins dependencies and if possible, set static versions instead of "latest". In that way, you can (in most cases) avoid using alpha/beta releases, which could be instable or not supporting your current environment.
I did this for solving it in my Flutter application.
Open the android/app project
Search the text androidx.core:core-ktx:+ in all solutions. In most cases this is found in build.gradle file.
If you found this text in some dependency, change androidx.core:core-ktx:+ to androidx.core:core-ktx:1.6.0
Sync and run again
In my case, I had this problem with the audioplayers: ^0.17.3 dependency. The + sign was causing the error.
I received this error in Android Studio when I created a new Android application. The latest versions of BOTH appcompat and core-ktx in dependencies appear to be the issue.
Open build.gradle, and look in dependencies
Roll back appcompat to 1.3.0
Roll back core-ktx to 1.6.0
Tap "Sync Now" (should be in the top right)
dependencies {
...
//implementation 'androidx.appcompat:appcompat:1.4.0'
//implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'androidx.core:core-ktx:1.6.0'
...
}
Rerun your program and cross your fingers.
I got the same error
C:\Users\pc.gradle\caches\transforms-2\files-2.1\7a25962662620ee4f1493c07e779c7ef\core-1.7.0\res\values\values.xml:105:5-114:25: AAPT: error:
resource android:attr/lStar not found.
fix this issue by =
replacing compileSdkVersion 30 in build.gradle
to
compileSdkVersion 31
Are you using the #react-native-community/netinfo library? You need to refresh this library if you are using it.
After updating or uninstalling and reinstalling the netinfo library it will work.
The solution for this error may change according to the platform which we are using for building the application.
For Cordova,
Reinstall cordova.plugins.diagnostic plugin
cordova plugin add cordova.plugins.diagnostic --variable ANDROIDX_VERSION=1.0.0
For React Native,
Reinstall #react-native-community/netinfo library
For Android Studio,
Specify specific or stable version of android core dependency in build.gradle(app) file.
dependencies {
...
implementation "androidx.core:core-ktx:1.6.0"
}
Major source of this issue is appcompat library. As a quick fix to run your project you can use appcompat version below 1.4.0 that is you can switch to appcompat version
implementation 'androidx.appcompat:appcompat:1.3.0'
or below.
remove dynamic version in project dependencies in all build.gradle files
example:
"androidx.core:core-ktx:+"
remove + or ^ operator in dependencies { } and mention specific version or stable version
"androidx.core:core-ktx:1.6.0"
source : https://flutter.dev/docs/development/packages-and-plugins/using-packages
If you are using React Native and started experiencing this issue later than November 4th 2022, it could be related to the next known issue: https://github.com/facebook/react-native/issues/35210
In order to try if this is what's causing your issue, you can upgrade react-native to the corresponding patch version specified in that link.
Doing that fixed the "error: resource android:attr/lStar not found" issue and two other issues that started suddenly happening for us, so it might be worth a try!
I resolved this issue by changing these compileSdkVersion 31, targetSdkVersion 31 and classpath 'com.android.tools.build:gradle:4.0.2'
this issue appeared with me in flutter and solved it thanks to this answer
https://issuetracker.google.com/issues/199180389#comment2
just adding the following to the bottom of our app/build.gradle seemed to work for us while our compileSdkVersion and targetSdkVersion remained at 29:
configurations.all {
resolutionStrategy {
force 'androidx.core:core:1.6.0'
force 'androidx.core:core-ktx:1.6.0'
}
}
Add the following to your Project build.gradle:
buildscript {
ext {
androidXCore = "1.6.0"
}
}
If anyone is facing the same issue in ionic cordova, remove these plugin
cordova-plugin-androidx
cordova-plugin-androidx-adapter
And also any plugins dependent on them.
I removed implementation androidx.core:core:1.7.0, the project did not depend on it, and now everything is OK.
Update the following code in your build.gradle(:app) file:
compileSdkVersion 31
targetSdkVersion 31
For Cordova
Uninstall cordova.plugins.diagnostic and cordova-plugin-androidx by running
cordova plugin remove cordova.plugins.diagnostic
cordova plugin remove cordova-plugin-androidx
I solved this problem by down grading my androidx.test.espresso:espresso-core from
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
to
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
All you have to do is go in build.gradle and erase the entire line:
implementation "androidx.core:core-ktx:+"
super easy
Update: This was also related to this for me
None of the other answers worked for me. As a last resort I watched a video in a foreign language and it worked for me. I was compiling to sdk 31
add this in the app build.gradle:
android {
...
configurations.all {
resolutionStrategy {
force 'androidx.appcompat:appcompat:1.3.0'
force 'androidx.core:core-ktx:1.6.0'
}
}
}
dependencies {
implementation "androidx.core:core-ktx:1.6.0"
implementation "androidx.appcompat:appcompat:1.3.0"
}
I got the from Saurabh Kumar but it wasn't working in android/build.gradle for some reason.
configurations.all {
resolutionStrategy {
force 'androidx.appcompat:appcompat:1.3.0'
force 'androidx.core:core-ktx:1.6.0'
}
}
Sorry I cannot comment as I just created an account. Thanks to Nitrix and Codemaker for the hints.
This is the complete list of commands in Ionic just to add to Codemaker's answer to get rid of the not found error
Android resource linking failed /Users/xxx/.gradle/caches/transforms-2/files-2.1/5d04bb4852dc27334fe36f129faf6500/res/values/values.xml:115:5-162:25: AAPT: error: resource android:attr/lStar not found.
npm uninstall cordova.plugins.diagnostic
rm -rf plugins/
rm -rf node_modules/
rm -rf package-lock.json
delete from package.json if diagnostic is still somewhere
npm install
ionic cordova platform rm android
cordova plugin add cordova.plugins.diagnostic --variable ANDROIDX_VERSION=1.0.0 // This probably cause an error if Capacitor is used or even lately it also causes error with Cordova, so just use the command below
npm install cordova.plugins.diagnostic --variable ANDROIDX_VERSION=1.0.0
npm install #ionic-native/diagnostic
ionic cordova platform add android
ionic cordova build android
I hope that this will help a bit.
comment this line in build.gradle
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
//implementation 'androidx.appcompat:appcompat:1.4.0'
that work's for me
I've had this happen a few times and it always happens when I upgrade my dependencies.
I solved this each time by updating the following items in my gradle files to the latest versions:
compileSdk
targetSdk
compileSdkVersion
buildToolsVersion
The buildToolsVersion has always been the one that has caused the problem.
when craete new project:
select Use legacy android.support librares
build.gradle (project)
buildscript { dependencies { classpath 'com.android.tools.build:gradle:4.0.2' } }
build.gradle (:app)
android {
compileSdkVersion 31
defaultConfig {
minSdkVersion 23
targetSdkVersion 31
}
}
dependencies {
def core_version = "1.7.0"
// Java language implementation
implementation "androidx.core:core:$core_version"
// Kotlin
implementation "androidx.core:core-ktx:$core_version"
}
Keep the same configuration of the app module for the feature modules so as not to generate inconsistencies.
GL
I solved this problem by down grading my appcompat lib from
implementation 'androidx.appcompat:appcompat:1.4.1'
To
implementation 'androidx.appcompat:appcompat:1.1.0'
For someone still trying to fix this while all of the above does not help, forcing dependency projects to build on the same SDK worked for me:
subprojects {
afterEvaluate {project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion = 31
buildToolsVersion = "31.0.0"
}
}
}
}
see https://github.com/react-native-image-picker/react-native-image-picker/issues/882
My situation is a bit different, I'm using mavenPublisher and don't want to upgrade the sdk version, so I need to put the configuration in library/build.gradle, it works for me.
configurations.all {
resolutionStrategy {
force 'androidx.core:core:1.6.0'
force 'androidx.core:core-ktx:1.6.0'
}
}
One major cause for this issue is the Gradle version difference between an added library and the projects build Gradle. This can result to a resource being unavailable during build time.
Matching the gradle versions can be an easy fix (If the library is you creation).
Use this::
buildscript {
ext {
buildToolsVersion = "31.0.0"
minSdkVersion = 21
compileSdkVersion = 31
targetSdkVersion = 31
androidXCore = "1.6.0"
}
}
This question already has answers here:
Running "cordova build android" - unable to find attribute android:fontVariationSettings and android:ttcIndex
(26 answers)
Closed 4 years ago.
I get following error while running the command "ionic cordova build android --stacktrace" :
:generateDebugResources
:mergeDebugResources
:processDebugManifest
:processDebugResources
ERROR: In <declare-styleable> FontFamilyFont, unable to find attribute android:fontVariationSettings
FAILED
ERROR: In <declare-styleable> FontFamilyFont, unable to find attribute android:ttcIndex
I am using following tools on Window's:
Editor : VScode
Ionic: C:\Users\xyz>ionic -version
3.19.1
Npm as packagemanager
Project Properties:
target=android-26
cordova.system.library.1=com.google.android.gms:play-services-analytics:+
cordova.system.library.2=com.facebook.android:facebook-android-sdk:4.+
cordova.gradle.include.1=cordova-plugin-appsflyer-sdk/customerapp-cordovaAF.gradle
cordova.gradle.include.2=twitter-connect-plugin/customerapp-twitter.gradle
cordova.system.library.3=com.android.support:support-v4:26.+
cordova.system.library.4=com.android.support:appcompat-v7:26.+
cordova.system.library.5=com.android.support:support-v4:24.1.1+
cordova.system.library.6=com.android.support:support-v4:+
android.library.reference.1=CordovaLib
I had to do the stuff of both the answers above:
In platforms/android/phonegap-plugin-barcodescanner:
Search for compile 'com.android.support:support-v4:+ and replace for compile 'com.android.support:support-v4:27+'.
In platforms/android:
Search for cordova.system.library.2=com.android.support:support-v4:+ and replace for cordova.system.library.2=com.android.support:support-v4:27.1.0.
Hope it helps.
Mine required a similar fix as above only it was in the de.appplant.cordova.plugin.local-notification plugin. I changed ‘com.android.support:support-v4:+’ to ‘com.android.support:support-v4:23+’ and then removed and added the android platform and it built. However, I had an extra brace '}' in my build-extras.gradle that had to be removed also.
found this on the ionic forum https://forum.ionicframework.com/t/android-build-broken-after-gradle-dependencies-update-execution-failed-for-task-processdebugresources-com-android-ide-common-process-processexception-failed-to-execute-aapt/109982/134 the suggestion that worked for me was "I got it working, my issue was in the cordova-plugin-file-opener2. Change com.android.support:support-v4:+ to com.android.support:support-v4:23+ in the plugin.xml for the cordova-plugin-file-opener2 in the plugins folder and the node_modules folder. Then do the same in the project.properties in platforms/android. My plugin however was the background-geolocation and actually i dont believe i had to make a fix in the project.properties for mine.
In my case, problem was in barcode scanner plug in. Removing and adding this plug in did not work, after all get it worked by changing 'com.android.support:support-v4:+' to 'com.android.support:support-v4:27+' in file 'platform/android/phonegap-plugin-barcodescanner/{projectName}-barcodescanner'. What I did not understand is project was working yesterday perfectly, what happened in 24 hours and this problem occured...
Had the same issue, what I did was following:
Clear the build directory
cordova clean
Add multiDexEnabled under android -> defaultConfig to the build.gradle file
"your project\platforms\android\app\build.gradle"
multiDexEnabled true
Change dependencies for "com.android.support" within the build.gradle file
com.android.support:support-v4:+ => com.android.support:support-v4:23+
Go through the plugins folder and look in all "plugins.xml" and replace:
com.android.support:support-v4:+ => com.android.support:support-v4:23+
Change project.properties under "platforms\android\project.properties"
cordova.system.library.4=com.android.support:support-v4:23+
Run "ionic cordova run build"
Unable to merge dex
https://stackoverflow.com/a/46591042
https://stackoverflow.com/a/47746531
Clean install
https://stackoverflow.com/a/24684622
Wrong Namespace / Version
https://stackoverflow.com/a/49164846
.
android {
defaultConfig {
multiDexEnabled true
versionCode cdvVersionCode ?: new BigInteger("" + privateHelpers.extractIntFromManifest("versionCode"))
applicationId privateHelpers.extractStringFromManifest("package")
if (cdvMinSdkVersion != null) {
minSdkVersion cdvMinSdkVersion
}
}
}
I did not find "com.android.support:support-v4:+" in the indicated paths of the topics I searched for, as I tried lastly in all folders and found in
platforms/android/phonegap-plugin-barcodescanner.gradle
in my case the plugin was the barcodescanner, in yours may be another.
then I followed the information and replaced with "'com.android.support:support-v4:27+" and it worked.
I was wondering if it was working perfectly yesterday, today I changed only one text and gave this error ... during the build I realized that some downloads occurred I believe that an update happened that caused this.
I was having the same problem out of the blue yesterday. It started randomly but from reading around, it looks like it is to do with an update as mentioned above by #cpro90. However, I tried and could not find where to make the necessary manual change.
Eventually I identified that the problem was being caused by my cordova-plugin-crosswalk-webview plugin. On Github, I found the issue on the plugin repro this morning and it had over 520 views by lunch.
#UNUMObile suggested the following in the build.gradle file to force an earlier version globally:
configurations.all {
resolutionStrategy.force 'com.android.support:support-v4:24.0.0'
}
This worked immediately for me and may help others with other plugins that also have had their dependancy on 'com.android.support:support-4:<28. The new version 28 seems to be the issue.
Hope this helps someone move forward.
Replacing 'com.android.support:support-v4:+' and 'com.android.support:support-v4:27+' with fixed versions in the plugin.xml didn't work for us - cordova crosswalk updated at least one support library to version 28.0.0-alpha1 though.
Forcing a fixed version of the support library for each dependency could solve the problem in the end.
configurations.all {
resolutionStrategy {
eachDependency { DependencyResolveDetails details ->
if (details.requested.group == 'com.android.support') {
details.useVersion "27.1.0"
}
}
}
I build the project at gitlab ci
./gradlew assembleDebug --stacktrace
and sometimes it throws an error:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformClassesWithDexBuilderForDebug'.
> com.android.build.api.transform.TransformException: java.lang.IllegalStateException: Dex archives: setting .DEX extension only for .CLASS files
At my local pc it works correctly.
kotlin version is 1.2
multidex is enabled
What is the reason of this error?
./gradlew clean fixed the same error for me.
For Cordova developers,
If you get this build error in your project, as said Pierrick Martellière in the comments of this answer, in you project folder use :
cordova clean
It makes a cleaning and a build immediately
It seems I found the solution.
At the build moment gradle was showing warnings for me:
Configuration 'compile' in project ':app' is deprecated. Use 'implementation' instead.
app: 'androidProcessor' dependencies won't be recognized as kapt annotation processors. Please change the configuration name to 'kapt' for these artifacts: 'com.arello-mobile:moxy-compiler:1.5.3' and apply the kapt plugin: "apply plugin: 'kotlin-kapt'".
I made a misspelling and forgot to remove unnecessary annotationProcessor for library:
annotationProcessor "com.arello-mobile:moxy-compiler:$moxyVersion"
kapt "com.arello-mobile:moxy-compiler:$moxyVersion"
So I removed first line.
After that I applied kapt plugin apply plugin: 'kotlin-kapt' and fixed some build errors in code after it.
After all I realized that I forgot to replace compile to implementation in some places. It is weird but without it build didn't work.
This changes fix my error build.
Simple Solution
For Ionic and Cordove Projects
cordova clean
Above answer is mostly right but in my case, i get this exception when i crate same name java and kotlin file then deletes one of them.
Solutions are: just Build -> Clean Project my project and it works. And my project also enabled multiDex.
defaultConfig {
...
// Enabling multidex support.
multiDexEnabled true
}
As mentioned above by #mixel cleaning gets the job done. But as an option not to do it manually just add the gradle 'clean' task into app run configuration so it will be done all the time before launch. Of cource, it can slow down the whole process a bit.
I was able to get the problem to go away by closing and restarting Android Studio. Perhaps even a Rebuild Project would have done it as well (did not try that though).
Configuring for multidexing did not solve this issue for me.
However I did come up with a resolution...of sorts. Basically it involved creating a pull request for a second branch on the same commit as the build that was failing. The build for this pull request succeeded, and then Bitbucket thought that the original pull request was ok and allowed us to merge, even though we had made no changes on that branch. There is some unexplained weirdness there but the technique worked.
Here's how I did it:
Assume that the branch that is failing is called bad-branch.
I created a new branch called bad-branch-copy on the commit that was common between bad-branch and develop. Then I merged bad-branch into bad-branch-copy. The end result of this was a fast forward such that bad-branch-copy ended up on the same commit as bad-branch. I was expecting a separate commit so this result surprised me, but I was grasping at straws anyway so I kept going.
I then pushed bad-branch-copy to GitHub and created a pull request from bad-branch-copy to develop. This triggered a build on bad-branch-copy -> develop, which was successful.
At that point, buddybuild showed a successful build on bad-branch-copy -> develop and still showed a failure on bad-branch -> develop. However, Bitbucket showed a successful build on the pull request for bad-branch. Yes, that's right: buddybuild showed a failure but Bitbucket said it was ok.
We were then able to merge the bad-branch pull request and all was well with the world. Please don't ask me why, I will not answer. :)
I think the same thing could be accomplished with
git checkout bad-build
git checkout -b bad-build-copy
git push origin bad-build-copy
followed by creating a pull request for bad-build-copy.
Currently using Android Studio 3.3.2 I just disabled the instant run and it worked.
What resolved the issue for me was manually adding all the conflicting files manually. For example in my gradle file I had:
implementation 'com.android.support:support-compat:27.1.1'
it was underlined with red. I hovered over the line and android studio said there was a conflict with another file using a lower version. The error was similar to
come.android.support:support-annotations:26.0.1 conflicts/mix versions with 27.1.1.
It gave me the names of the files and I manually added them with the corresponding version so they would all match
compile 'com.android.support:support-annotations:27.1.1'
compile 'com.android.support:support-compat:27.1.1'
compile 'com.android.support:support-core-ui:27.1.1'
compile 'com.android.support:animated-vector-drawable:27.1.1'
compile 'com.android.support:appcompat-v7:27.1.1'
compile 'com.android.support:design:27.1.1'
None of the current solutions worked for me and it was fixed by simply disabling Instant Run.
please find here the solution of this problem,
defaultConfig {
...
minSdkVersion 14
targetSdkVersion 21
...
// Enabling multidex support.
multiDexEnabled true
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
}
I am facing this error
Error:Execution failed for task ':app:processDebugGoogleServices'.
File google-services.json is missing. The Google Services Plugin cannot
function without it.
Searched Location:
C:\Users\Kartik\AndroidStudioProjects\barcode\app\src\debug\google-
services.json
C:\Users\Kartik\AndroidStudioProjects\barcode\app\google-services.json
I have added this path in build.gradle(project:barcode)
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.google.gms:google-services:3.0.0'
and added this in build.gradle(Module:app)
apply plugin: 'com.google.gms.google-services'
I have also added the google-services.json file in project->app folder but then also it is giving the same error.
i faced the same problem before .
check the json file name and make sure that there is no additional spaces
First of all please make sure that you have followed documentation for firebase and not google developers guidelines and alspo generated Google-services.json for firebase project that is running in your firebase-console, you can see all your running projects in your dashboard in firebase
Make sure you have correct json file, this problem is describe here.
You can follow these steps also as per firebase documentaion.
still if you are all correct and getting errors make sure you have updated play services version in your SDK and also put this line in your app module build.gradle file, to make sure that multidex is unable. Hope you will make something out of it.
defaultConfig {
multiDexEnabled true
}
I want to upgrade gradle to 2.0.0-beta or 1.5.0, I have the dex plugin in my gradle at the moment, but even when I removed it I was still getting the same error. How do I properly get rid of the multidex dependency
Error:Access to the dex task is now impossible, starting with 1.4.0
1.4.0 introduces a new Transform API allowing manipulation of the .class files.
See more information: http://tools.android.com/tech-docs/new-build-system/transform-api
build.gradle More info on multidex
android {
compileSdkVersion 21
buildToolsVersion "21.1.0"
defaultConfig {
...
minSdkVersion 14
targetSdkVersion 21
...
// Enabling multidex support.
multiDexEnabled true
}
...
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
}
The Transform API doesn't give too much info.
Is there any to get this work or any examples how to use the transform api, anything at all?
I know it works with 1.3.0, I need at least 1.5.0
At the project level build.gradle, put this (or whatever version you need)
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
As far as
How do I properly get rid of the multidex dependency?
You need to remove all references to multidex in the Gradle files, then sync Gradle and clean and rebuild the project
I'm not sure if it's going to help. I got a similar error and I deleted the directory which contained that dex file. The path was C:\Users\user\AndroidStudioProjects\AppName\app\build\intermediates\builds\debug\37393618208634. After deleting that directory it worked. You can try this if that does't work you can just put it back. I hope this helps.