Error - Android resource linking failed (AAPT2 27.0.3 Daemon #0)
Asked Answered
C

41

129

I have this error

I am try reinstall android studio and remove .gradle folder , any solution please?

    Error:FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugResources'.
> Android resource linking failed (AAPT2 27.0.3 Daemon #0)
  Command: C:\javasdk\build-tools\27.0.3\aapt2.exe link -I\
          C:\javasdk\platforms\android-26\android.jar\
          --manifest\



  C:\Users\Jalal D\.gradle\caches\transforms-1\files-1.1\fonticon-0.1.8.aar\2b09376fc14469ba65fc8e4d85c2eed1\res\values\values.xml:19:5-25:25: AAPT: error: resource android:attr/fontVariationSettings not found.

  C:\Users\Jalal D\.gradle\caches\transforms-1\files-1.1\fonticon-0.1.8.aar\2b09376fc14469ba65fc8e4d85c2eed1\res\values\values.xml:19:5-25:25: AAPT: error: resource android:attr/ttcIndex not found.

  error: failed linking references.

* Try:
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

BUILD FAILED in 1m 3s
Crouton answered 8/3, 2018 at 10:38 Comment(1)
Please check here Hope it may help you:)Paddlefish
O
53

Had exactly the same problem. Solved it by doing the following: Searching for and replacing com.android.support:support-v4:+ with com.android.support:support-v4:27.1.0 in the platform/android directory.

Also I had to add the following code to the platforms/android/app/build.gradle and platforms/android/build.gradle files:

configurations.all {
resolutionStrategy {
    force 'com.android.support:support-v4:27.1.0'
}}

Edited to answer "Where is this com.android.support:support-v4:+ setting ?" ...

The setting will probably(in this case) be in one of your plugin's .gradle file in the platform/android/ directory, for example in my case it was the starter-barcodescanner plugin so just go through all your plugins .gradle files :

enter image description here

Double check the platforms/android/build.gradle file.

Hope this helps.

Ostrogoth answered 8/3, 2018 at 13:21 Comment(5)
Thank you saved us!Tallulah
Thanks you save my day!!I had days with this problem that came out of the night to me without knowing how my application had stopped workingShawnna
Cant believe the solution was so simple, all it took was a copy paste to those two gradle files! Claps!!Melatonin
Found one of the reason of this problem When we use any string,style,color,etc, in manifest that is not present in values (string.xml,style.xml,color.xml,etc,) then this type of error occer's.Enzyme
This fix also works when dependencies are updated in Android studio. IDE itself will point out in the files that these versions must match the compiledSDKCalefactory
K
139

The Android resource linking failed error can also appear if you have an error in any of your XML resources. In my case I was using the following line twice in one of my XML drawables in drawable folder:

<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>

I removed the duplicate line and the error disappeared. The error was a bit misleading:

Android resource linking failed Output: /Users/johndoe/Desktop/myapp/app/src/main/res/layout/activity_main.xml:2: error: resource drawable/bg_main (aka com.example.myproject:drawable/bg_main) not found.

According to the above error, the first thing you need to do is to proof read all the drawable resources that are accessed in the activity_main because the chances are higher that you will find the error. In the worst case scenario you might end up checking all your resource files.

Kaleb answered 6/12, 2018 at 4:11 Comment(6)
This. This solved my problem. It's very annoying that this error was not signaled by the IDE and the linking error ws talking about something else completely.Tonetic
mother of god !Pigmentation
mine was actually: <?xml version="1.0" encoding="UTF-8"?><?xml version="1.0" encoding="UTF-8"?> (on the same line :P harder to detect)Beguine
Mine was that I was using a resource in Manifest while it already deleted <meta-data android:name="com.google.android.actions" android:resource="@xml/my_event_session_menu" />Impart
+1 for saving me some time. What's most annoying is that Android Studio pointed to the wrong file, which caused me to scratch my head as the file it said it couldn't link to was fine.Heshvan
For me it was a spelling error in nav_graph.xmlMariomariology
O
53

Had exactly the same problem. Solved it by doing the following: Searching for and replacing com.android.support:support-v4:+ with com.android.support:support-v4:27.1.0 in the platform/android directory.

Also I had to add the following code to the platforms/android/app/build.gradle and platforms/android/build.gradle files:

configurations.all {
resolutionStrategy {
    force 'com.android.support:support-v4:27.1.0'
}}

Edited to answer "Where is this com.android.support:support-v4:+ setting ?" ...

The setting will probably(in this case) be in one of your plugin's .gradle file in the platform/android/ directory, for example in my case it was the starter-barcodescanner plugin so just go through all your plugins .gradle files :

enter image description here

Double check the platforms/android/build.gradle file.

Hope this helps.

Ostrogoth answered 8/3, 2018 at 13:21 Comment(5)
Thank you saved us!Tallulah
Thanks you save my day!!I had days with this problem that came out of the night to me without knowing how my application had stopped workingShawnna
Cant believe the solution was so simple, all it took was a copy paste to those two gradle files! Claps!!Melatonin
Found one of the reason of this problem When we use any string,style,color,etc, in manifest that is not present in values (string.xml,style.xml,color.xml,etc,) then this type of error occer's.Enzyme
This fix also works when dependencies are updated in Android studio. IDE itself will point out in the files that these versions must match the compiledSDKCalefactory
P
51

Note: Android Studio spits out a load of crazy errors like this if you upgrade the support libraries to 28.0.0 and your compileSdkVersion is not 28 also.

Pieplant answered 17/10, 2018 at 23:32 Comment(4)
I already had both compileSdkVersion 28 and support-v4:28.0.0 and I'm getting the same error :(Tonetic
@Tonetic I fixed the issue by downgrading the compileSdkVersion to 27Showplace
+1. My project has two modules and I had different versions (one was 29 and the other was 27). When I set all them to 29 the error was goneEulalie
Thanks! In my case I had to set 'minSdkVersion' to the same as 'compileSdkVersion'. Otherwise only the first build would run, and all consequent re-runs would fail with a similar error as OPTaeniacide
G
10

Problem fixed for me by replacing compileSdkVersion 23 with compileSdkVersion 28 in build.gradle (Project: build).

Gooding answered 29/4, 2019 at 22:59 Comment(4)
Worked for me, thanks! I still have minSdkVersion 23Baggage
@StephenHosking Did it work for you without upgrading compileSdkVersion from 23 to 28? In that case, what was the issue that you were originally experiencing?Gooding
I should have been more clear. Your solution, ie. replace compileSdkVersion 23 with compileSdkVersion 28 worked for me, but I just mentioned that was able to leave minSdkVersion 23, as extra info on a correct solution. My original problem was "Error - Android resource linking failed"Baggage
@StephenHosking Nice. Good that is works for you now.Gooding
P
7

In your layout (xml) files almost every element has a property i.e. "id" which, can be assigned in order to refer to it from the java/kotlin code or from the xml itself.

Now sometimes or in some versions of Android Studio errors in xml files is either not reported or some random error is thrown while compiling, of which, this thread is an example i.e. when assigning an id to an element or when refering to another element in the layout we use the ID but ids are not just written like any other word rather they are prefixed by these characters: @+id/, otherwise the above error is thrown.

Hence the solution below should be considered:-

I resolved it by adding @+id/ before all my IDs.

i.e. @+id/your_item_id

Phalarope answered 7/8, 2018 at 6:18 Comment(2)
This is not provide right answer to the question. provide a right answer and how u did it and what is the problem of it?. \Onomasiology
@YohanMalshika I have updated my answer, check to see if it works for you now. Sorry for the late reply!Phalarope
P
7

If you are using Windows 10, and Android Studio 3.2, you can simply go to the app's build.gradle, and change the version.

Under dependencies, change version, and build/sync

Poker answered 27/9, 2018 at 8:17 Comment(2)
It is the Module Gradle. Click on link above to see screenshot.Poker
Is Windows 10 a requirement?Comedietta
S
7

For me, the error appeared after changing my launcher icon using Asset Studio in Android Studio. Turns out that the ic_launcher_foreground.xml file that was generated was missing the following line at the top of the XML file:

<?xml version="1.0" encoding="utf-8"?>
Songer answered 3/3, 2019 at 16:35 Comment(1)
Mine was similar. I added a new Build Variant and had two of these errors. The first one made no sense, but I dug into the second error and found that this build was missing ic_launcher.pngLeifeste
D
4

feel so stupid - (for whatever reason) i had one empty xml in drawable folder. and AS produced dozens of unrelated errors ><

so, my general advice would be the same - check briefly every resource file.

Drift answered 10/6, 2019 at 21:13 Comment(0)
C
3

com.android.support:support-v4 just recently got update and maybe affect to plugin that use updated version in their dependencies. But if you cannot find in the dependencies (like if you use crosswalk plugin), just put this code in top of your code gradle plugin (no need to add on build.gradle).

configurations.all {
resolutionStrategy.force 'com.android.support:support-v4:24.0.0'
}

Example location to put the code in crosswalk plugin here

Feel free to edit version of com.android.support (DO NOT USE THE 28.0.0) because thats the problem

Camphor answered 9/3, 2018 at 1:48 Comment(1)
Thanks a lot. I am using 27.1.0 as @Ostrogoth mentioned.Tallulah
J
3

I imported new colors to my project and got the same problem. So I opened styles.xml and re-assigned items to colors using new colors names.

Josuejosy answered 13/12, 2018 at 16:49 Comment(0)
C
3

I had the same problem and solved it by going to File -> Project Structure... -> Suggestions and then Apply all. Like suggested by @JeffinJ I think the problem was because of the Gradle plugin update.

Cho answered 28/2, 2020 at 8:56 Comment(0)
A
3

I was missing this line at the top of one of my XMLs:

<?xml version="1.0" encoding="utf-8"?>
Awesome answered 22/3, 2021 at 11:18 Comment(0)
L
2

There should be some error in resource files. It mean is there may be miss typed value of attributes. Go through the resource files and correct these value and enjoy the work.

Likely answered 15/10, 2018 at 20:18 Comment(0)
P
2

There can be multiple reasons for this problem and these reasons are mainly in the resource or app level build.gradle file.

In my case, a view in the resource file didn't had the required dependency included in the build.gradle file.

So, make sure to include all the required dependencies in the build.gradle file.

Pairs answered 6/2, 2019 at 18:49 Comment(0)
S
2

Check your Gradle plugin version. Try downgrading it if you have updated to a newer version just before this issue showed up. Go to File -> Project Structure. Change to the previous version.

Sain answered 13/6, 2019 at 5:35 Comment(0)
G
1

Try update latest build version, target and compile version and also update dependencies but not works for me

In my case change <meta-items/> to <meta-data/> in manifest works for me...

Hope its helpful for someone...

Goode answered 28/5, 2018 at 6:41 Comment(0)
R
1

I had the same problem, but it was because in my buttons layout_width/height I forgot to put dp at the end when editing them. Added dp and problem fixed :/

Radiate answered 24/1, 2019 at 1:2 Comment(0)
T
1

In my case I accidentally wrote:

app:displayViewTitle="@string/instructions_defineExtract_confirm_email"

Interestingly, Android Studio were able to navigate the string via CTRL+click. It was just giving Build Time error. Changing to standard "dot seperation" did the trick

app:displayViewTitle="@string/instructions.defineExtract.confirm.email"
Tatyanatau answered 15/4, 2019 at 12:37 Comment(0)
P
1

i got the same bug, and i fixed it when i close the AndroidStudio and delete the dir like C:\Users\Jalal D\.gradle\caches\transforms-1\ in the build error info.

Pronghorn answered 27/2, 2020 at 3:1 Comment(0)
U
1

I was an issue like this with the drawable.

Spent almost 7 hours. tried everything from Google and SO. Nothing worked

then took rest reopned the file just watch the codes and suddenly it clicked to my mind that the image files I named as spalsh instead of splash!

Those 7 hours!!!! just only a small mistake and so much stress.

Somethings nothin works except a miracle like this

Unleash answered 9/8, 2021 at 19:12 Comment(1)
I do share your frustration. I've been there.Cypsela
G
1

check your manifest file because it may refer to some resource that are not found in res folder.

Gladiate answered 28/12, 2022 at 18:40 Comment(0)
A
1

FIXED

I fixed this issue by adding translatable="false" for each string resource:

<resources>
    <string name="app_name" translatable="false">MEVENDA TN</string>
    <string name="title_activity_main" translatable="false">MEVENDA TN</string>
    <string name="package_name" translatable="false">tn.mevenda.m</string>
    <string name="custom_url_scheme" translatable="false">tn.mevenda.m</string>
</resources>

Check Android Studio suggestions to fix this.

enter image description here

Altitude answered 16/2, 2023 at 3:31 Comment(0)
C
0

I was having similar problem but I came out of the solution the problem was that you were using any thing in the dependency that correspond to same domain but with different versions make sure those all are same

Claireclairobscure answered 30/10, 2018 at 16:28 Comment(1)
I installed Android Studio 3.3.2 last night. I am a complete newbie. I created a "Flutter" application and tried to run it. I get the following output and linking failure message:Remonstrant
D
0

I was facing same issue and it is resolved by removing error from resource files like style, colors files in values folder. In my case, error in style colors as below:

 <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
    <item name="android:textColorPrimary">**@color/colorPrimary**</item>
    <item name="android:textColorSecondary">**@color/colorPrimaryDark**</item>
</style>
Danas answered 3/1, 2019 at 11:33 Comment(0)
E
0

Changing the version of the support library of the last one enabled (28.0.0) by the previous (27.1.0), the error Android Resource Linking Failed disappeared.

It should be noted that version 27.1.0 is the maximum allowed in our implementations, which works, but you could use an older one if you wish. And this has to be used in all dependencies that start with the string com.android.support:

project/app/build.gradle

implementation "com.android.support:appcompat-v7:$rootProject.supportLibraryVersion"
implementation "com.android.support:support-v4:$rootProject.supportLibraryVersion"

project/build.gradle

ext {
    supportLibraryVersion= '27.1.0'
}

Then, Sync Project with Gradle Files

GL

Edmundedmunda answered 11/1, 2019 at 7:29 Comment(0)
L
0

Same issue occurred for me, but before getting this error, my app was running. So I just did undo 2/3 times. And did changes again. And build app.app ran successfully.

Lucillalucille answered 1/2, 2019 at 16:18 Comment(0)
Z
0

I've come across the same issue after adding the following dependency:

implementation 'com.evernote:android-state:1.4.1'
annotationProcessor 'com.evernote:android-state-processor:1.4.1'

And the reason was that latest version of evernote uses dependencies to AndroidX, while I had support library version 27.1.1 in my project. So there was an option of upgrading support libraries to 28.0.0, as the other answers suggest, but that was a bit tricky for a large project with lots of custom views. So, I resolved the issue by downgrading evernote version to 1.3.1.

Zamora answered 14/2, 2019 at 7:44 Comment(0)
B
0

It may sound banal, but for me Build > Clean Project fixed this error without any other changes.

Boxhaul answered 1/3, 2019 at 9:40 Comment(0)
C
0

I'm using Studio 3.3.1 Build from Jan 28.

For me I was getting the "error android resource linking failed" pointing to a line in a layout file using ConstraintLayout that had been working correctly until today when the only change to my app level gradle file was to update the versions of:

android.arch.navigation:navigation-fragment
android.arch.navigation:navigation-ui

from 1.0.0-rc01 to 1.0.0-rc02.

The error message said something about not recognizing layout_constraintTop_toTopOf which of course is silly because it had been compiling quite happily for months.

I am already on 28.0.3 of build tools and compileSdkVersion of 28. I've been using androidx.appcompat everywhere for a while now (converted this project months back to androidx).

I first went through a project clean (no help), and invalidating cache/restart (no help). The layout in question had been originally defined using

<TextView>, <EditText> and <ImageView> components (which had been working fine until today).

But after reading the above answers I thought maybe somehow there was confusion being caused here so I changed the layout to use:

<androidx.appcompat.widget

versions of all the various components. No change - still got the error.

I then deleted the <androidx.appcompat.widget.AppCompatTextView block that was causing the compilation error. I changed all references to it in the other widgets to refer to "parent" instead. Did a Make. This time the compile completed without error.

So something strange in that widget definition I thought....here is what it was:

<androidx.appcompat.widget.AppCompatTextView
    android:id="@+id/contact_firstname_label"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:text="@string/contact_fname_label"
    android:gravity="end"
    android:textAppearance="@android:style/TextAppearance.Material.Small"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toLeftOf="@+id/contact_detail_fname"
    app:layout_constraintBaseline_toBaselineOf="@+id/contact_detail_fname"/>

I then pasted back the block I had Ctrl-V cut previously and changed the references back to that ID in the other components that reference it in the layout. Compile failed.

I cut the block again and pasted it to WordPad. Then reading from the WordPad paste, I actually typed it back in (i.e. I didn't copy/paste this time) - line by line, doing a make on the project after I typed in the minimal definition, and then again thereafter when I put in each new line. Each time the project compiled cleanly!

I don't know what to make of this. Perhaps some spurious invisible character was in the file originally?

Cusk answered 4/3, 2019 at 16:32 Comment(0)
E
0

Found one of the reasons which causes this problem

When we try to use any

string,style,color,etc,

in manifest file that is not present in values (string.xml,style.xml,color.xml,etc,) then this type of error occurs

Enzyme answered 3/4, 2019 at 10:13 Comment(0)
R
0

In my case I styled by accident a property present only in buttons and added that style for a TextView.

<!-- applied to TextViews -->
<style name="rowStyle"> 
    <item name="android:padding">3dp</item>
    <item name="android:borderlessButtonStyle">false</item> <!-- this caused the error -->
    <item name="android:background">@drawable/textview_border</item>
</style>

Removing the row with android:borderlessButtonStyle fixed the problem.

Robinia answered 8/4, 2020 at 16:6 Comment(0)
A
0
  • Right click on the drawable folder and select "Show in Explorer".
  • Find the failing file in the opened file system, select them (or select the files in the entire drawable), then copy them to the drawable-v24 file (do not delete the drawable file and create it if there is no drawable-v24 file).
  • Then choose File -> Invalidate Caches / Restart and
  • restart Android Studio.
Acclimate answered 11/4, 2020 at 12:4 Comment(1)
Point 1 & 2 Works For me. But now i need to place failing files in two places one in drawable and other in drawable-v24.Maher
I
0

In case you run into this: in my case I had a translated string, but the string did not yet appear in the default strings.xml. Added the missing string to strings.xml and it got resolved.

Inhibitory answered 26/10, 2020 at 17:25 Comment(0)
D
0

In my case the error was pointing to the AndroidManifest.xml file. I had this line:

<meta-data
            android:name="com.google.android.actions"
            android:resource="@xml/popup_info.xml" />

Which, I'm not sure why Android Studio put that there. I didn't change my manifest file, and this never happened until I upgraded to version 3.5.3 - so AS must have done it for me. Anyway, the line should have looked like this:

<meta-data
            android:name="com.google.android.actions"
            android:resource="@layout/popup" />

Once I changed that, it was all good.

Dalessandro answered 30/10, 2020 at 13:37 Comment(0)
S
0

I encountered the same error and I was missing @+id/ in one of constrained

        app:layout_constraintEnd_toEndOf="btn_join"

It was fixed once I added @+id/ just like below :

        app:layout_constraintEnd_toEndOf="@+id/btn_join"
Savona answered 5/8, 2021 at 2:30 Comment(0)
B
0

I changed the names and values inside my colors.xml,
and forgot to update themes.xml (night) with the new color names.
Replacing the old color names with the new names solved the problem.

Belmonte answered 21/1, 2022 at 17:46 Comment(0)
L
0

This happened when I deleted/modified a file from the drawable folder that was being used by an xml file, reverting this back fixed the issue. But for some reason the Android Studio didn't show the exact location of the error.

Leblanc answered 25/1, 2022 at 10:22 Comment(0)
G
0

In my case, I deleted the material library:

com.google.android.material:material:1.6.1

Once I got it back, it started working again. (The Themes used in the default app template uses this library).

Goatskin answered 14/6, 2022 at 22:28 Comment(0)
H
0

I simply tried Build>Make Project and it worked!

Highgrade answered 12/11, 2022 at 10:10 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Keelung
P
0

Sharing my mistake just in case someone else makes the same ham fisted blunder:

Mistakenly added res/values folder (and the style.xml file contained within) to src/main/java instead of src/main. The IDE won't flag it.

(visual below)

:module-name
  - build
  - src
    - main
      - java
        - ... // Resources DON'T go here (check indentation)
      - res // Resources go here
        - values
          - style.xml

:facepalm:

Psychoneurosis answered 11/10, 2023 at 1:34 Comment(0)
M
0

One reason could it be: Java Version

Check your supported Java Version in Android Studio: Project Setting> Build> BuildTools> Gradle

For me my project only support Java_v11, instead of v21 or v17.

Miscarriage answered 30/1 at 7:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.