8
votes

So everything was working perfectly, and as i went and edited some .xml files and built the project, now i am getting a gradle error that says :

Android resource linking failed Output: H:\AndroidProjects\Codify\app\src\main\res\layout\activity_app_setup.xml:19: error: resource drawable/toolbarbackground (aka com.femindharamshi.spa:drawable/toolbarbackground) not found. H:\AndroidProjects\Codify\app\src\main\res\layout\content_main.xml:20: error: resource drawable/toolbarbackground (aka com.femindharamshi.spa:drawable/toolbarbackground) not found. H:\AndroidProjects\Codify\app\src\main\res\layout\content_main.xml:34: error: resource drawable/menu (aka com.femindharamshi.spa:drawable/menu) not found. H:\AndroidProjects\Codify\app\src\main\res\layout\dialog_layout.xml:9: error: resource drawable/dialog_item (aka com.femindharamshi.spa:drawable/dialog_item) not found. H:\AndroidProjects\Codify\app\src\main\res\layout\dialog_layout.xml:17: error: resource drawable/programmer (aka com.femindharamshi.spa:drawable/programmer) not found. H:\AndroidProjects\Codify\app\src\main\res\layout\dialog_layout.xml:37: error: resource drawable/dialog_item (aka com.femindharamshi.spa:drawable/dialog_item) not found. H:\AndroidProjects\Codify\app\src\main\res\layout\dialog_layout.xml:45: error: resource drawable/youtube (aka com.femindharamshi.spa:drawable/youtube) not found. H:\AndroidProjects\Codify\app\src\main\res\layout\dialog_layout.xml:65: error: resource drawable/dialog_item (aka com.femindharamshi.spa:drawable/dialog_item) not found. H:\AndroidProjects\Codify\app\src\main\res\layout\dialog_layout.xml:73: error: resource drawable/meeting (aka com.femindharamshi.spa:drawable/meeting) not found. H:\AndroidProjects\Codify\app\src\main\res\layout\fragment_code.xml:15: error: resource drawable/tagbackground (aka com.femindharamshi.spa:drawable/tagbackground) not found. H:\AndroidProjects\Codify\app\src\main\res\layout\tag_layout.xml:12: error: resource drawable/tagbackground (aka com.femindharamshi.spa:drawable/tagbackground) not found. H:\AndroidProjects\Codify\app\src\main\res\layout\video_layout.xml:17: error: resource drawable/play (aka com.femindharamshi.spa:drawable/play) not found. H:\AndroidProjects\Codify\app\src\main\res\menu\activity_main_drawer.xml:7: error: resource drawable/download (aka com.femindharamshi.spa:drawable/download) not found. H:\AndroidProjects\Codify\app\src\main\res\menu\activity_main_drawer.xml:15: error: resource drawable/settings (aka com.femindharamshi.spa:drawable/settings) not found. H:\AndroidProjects\Codify\app\src\main\res\menu\activity_main_drawer.xml:19: error: resource drawable/report (aka com.femindharamshi.spa:drawable/report) not found. H:\AndroidProjects\Codify\app\src\main\res\menu\activity_main_drawer.xml:27: error: resource drawable/ic_menu_share (aka com.femindharamshi.spa:drawable/ic_menu_share) not found. error: failed linking file resources.

Command: C:\Users\Femin Dharamshi.gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar\d614b8b16e66b30fe0890919a84f61db\aapt2-3.2.1-4818971-windows\aapt2.exe link -I\ C:\Users\Femin Dharamshi\AppData\Local\Android\Sdk\platforms\android-28\android.jar\ --manifest\ H:\AndroidProjects\Codify\app\build\intermediates\merged_manifests\debug\processDebugManifest\merged\AndroidManifest.xml\ -o\ H:\AndroidProjects\Codify\app\build\intermediates\processed_res\debug\processDebugResources\out\resources-debug.ap_\ -R\ @H:\AndroidProjects\Codify\app\build\intermediates\incremental\processDebugResources\resources-list-for-resources-debug.ap_.txt\ --auto-add-overlay\ --java\ H:\AndroidProjects\Codify\app\build\generated\not_namespaced_r_class_sources\debug\processDebugResources\r\ --custom-package\ com.femindharamshi.spa\ -0\ apk\ --output-text-symbols\ H:\AndroidProjects\Codify\app\build\intermediates\symbols\debug\R.txt\ --no-version-vectors Daemon: AAPT2 aapt2-3.2.1-4818971-windows Daemon #0

But i have not editing any xml files that would cause this issue and as you can clearly see in the screen shot, all the files are present which Android Studio tells "not found"

What is causing this abrupt problem and how can i resolve it ? I check all my implementation libraries were up to date and non of the solutions online helped!

EDIT: I transferred all the files from drawable folder to drawable-v24 folder and it solved the issue. I really cannot understand what caused this issue as everything was working perfectly before and suddenly this problem also it weirdly solved by transferring the files, but before it didnt give a problem if they were in the drawable folder

Screenshot of the problem

1
The problem is not over implementation or gradle file. / Can you delete Gradle,Build,.idea file of your project and then do Rebuild project. - Prince Dholakiya
Otherwise -> Go to File menu -> Click on Invalidate cache / Restart . - Prince Dholakiya
could not locate invalidate cache ! where is it exactly, it is not under file - Femn Dharamshi
Click on File option on the top right -> Invalidate cache / restart. - Prince Dholakiya

1 Answers

6
votes

I have just had a very similiar problem.

Check if you can locate the resource file 'R' in one of the java subfolders of your project. It sounds as if the location of the resourc file cannot be determined. If you cant locate it, it might be deleted off and that may be the reason why there is a linking error. In my case it got deleted when I created a Google Maps activity.

If you cannot locate it: Try: Build -> Clean Project That cleans the gradle file

Alternatively: File->Invalidate Caches Then sync the project with gradle files

Give these a go and see if it changes anything. It may restore the resource file. If it doesnt, I would suggest creating a new project and copying and pasting the code from the 'old' project into the new one. This way you can make sure the resource file is restored and it should eliminate the linking error. You'd have to create all xml files and java classes again, but depending on the size of your project it might be faster than trying to restore the resource file.