gpt4 book ai didi

java - Gradle 报错 Android Resource linking Failed

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:50:52 29 4
gpt4 key购买 nike

所以一切都运行良好,当我去编辑一些 .xml 文件并构建项目时,现在我收到一个 gradle 错误,上面写着:

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

但我没有编辑任何会导致此问题的 xml 文件,正如您在屏幕截图中清楚地看到的那样,Android Studio 显示“未找到”的所有文件都存在

是什么导致了这个突发问题,我该如何解决?我检查了我所有的实现库都是最新的,但没有在线解决方案提供帮助!

编辑: 我将所有文件从 drawable 文件夹转移到 drawable-v24 文件夹,它解决了这个问题。我真的不明白是什么导致了这个问题,因为之前一切正常,突然间这个问题也通过传输文件奇怪地解决了,但是之前如果它们在可绘制文件夹中就没有问题

Screenshot of the problem

最佳答案

我刚刚遇到了一个非常相似的问题。

检查您是否可以在项目的 java 子文件夹之一中找到资源文件“R”。听起来好像无法确定资源文件的位置。如果找不到它,它可能会被删除,这可能是出现链接错误的原因。就我而言,它在我创建 Google map Activity 时被删除了。

如果找不到它:尝试:Build -> Clean Project 清理 gradle 文件

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

试一试,看看它是否有任何改变。它可以恢复资源文件。如果没有,我会建议创建一个新项目并将代码从“旧”项目复制并粘贴到新项目中。这样您可以确保资源文件已恢复并且应该消除链接错误。您必须重新创建所有 xml 文件和 java 类,但根据项目的大小,这可能比尝试恢复资源文件更快。

关于java - Gradle 报错 Android Resource linking Failed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53676954/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com