- [SOLVED] Android resource linking failed Error: failed linking file resources.
- Cause
- Solution
- Tips to finding the problem XML quickly
- How to Fix Android Resource Linking Failed Error
- Error: failed linking file resources – The Cause
- Android Resource Linking Failed Error – The solution
- 1. Open Every XML file
- 2. Run a Stacktrace
- 3. Undo the Changes
- Conclusion
- Android resource linking failed : Unity Error :unexpected element found in #1551
- Comments
- AliAhmadUnityDev commented Jan 13, 2021
- Step 0: Are you in the right place?
- [REQUIRED] Step 1: Describe your environment
- [REQUIRED] Step 2: Describe the problem
- Steps to reproduce:
- Relevant Code:
[SOLVED] Android resource linking failed Error: failed linking file resources.
- Posted by Finco Agbontaen
- 2 Comments
- Categories: Android Errors & Solutions, Tutorials
This error sometimes also comes as “Android resource linking failed” is another frequent and vague error in Android Studio. The solution sometimes could be quite boring and painful but I assure you, this error is absolutely nothing serious.
Cause
The error shows up when Gradle encounters an error (Usually a syntax or typo error) in one or more of your XML files.
Most of the XML files are located in the res folder, however, you might still find some outside the res folder. For example, the AndroidManifest.xml located in “/src/main/AndroidManifest.xml”. Here is an example of a layout file that would give the “Error: failed linking file resources” error.
Note the “android:endCollor” attribute.
Solution
The solution to the error is obvious, right? All you have to do is go through each of your XML files to figure out where the error might be. This could sometimes be time-consuming but be rest assured that the error will disappear as soon as you find and fix the problem child (problem XML).
You might be lucky and Android Studio will point you in the exact direction as shown in the screenshot below:
Other times like when you are using an older version of Android Studio, the error would not be this specific.
Tips to finding the problem XML quickly
If you have a lot of XML files and it would be just too difficult to go through them one after the other, you could use the following tips to make the process easier:
- Undo: Most times, you are already halfway through a project before you experience this issue. Meaning that it was a recent change to one of your XML files that caused the issue. If that is the case, you can try to undo your recent change to the XML files. To undo, simply use the key combination: Ctrl+Z.
- Open every XML file: The second method involves simply opening every single XML file in your project (Without scanning). The reason for this is that sometimes, after opening the problem XML file, Android Studio then detects the error and underlines it.
If you enjoyed this post, feel free to share it. If you have any questions, feel free to ask them in the comment box below. 🙂
Источник
How to Fix Android Resource Linking Failed Error
“Android Resource Linking Failed” is one of the commonest error messages encountered by Android developers while working with Android Studio. Most of them usually cannot figure out the exact cause of the issue and fix it. It’s obviously a boring and painful job to debug the whole code and get rid of the resource linking problem. But today we’ve come up with a sure-shot solution for the problem and we’re damn sure that you can fix it today itself by spending a couple of minutes.
Although it not a serious issue, it’s a good thing to know how the issue arises and what might be the reasons behind that. So let’s explain things clearly so that you can eliminate such errors in the future.
Error: failed linking file resources – The Cause
Usually, this error occurs while the Android Studio Gradle encounters some errors in one or more of your XML files. This may be sometimes a syntax error or simple a typo.
Although the XML files are located in the res folder, you need to check whether there are any files located outside of the folder and you have to debug that too. I’ll explain with an example:
Suppose the AndroidManifest.xml is located in “/src/main/AndroidManifest.xml”.
A layout file that probably gives the Android resource linking failed error looks something like this:
Not down the android:endCollor attribute .
Android Resource Linking Failed Error – The solution
For fixing this error, all you need to do is to manually check each of the XML files and find out the issue. Just run the code and the Android Studio will help you figure out the issue most of the time. This is because the latest version of Android Studio will point of the error specifically so that you can save the time to debug it.
Just in case, you are using an older version of the Android Studio, the error would not be specific and will take some time to debug.
Moreover, if you have a few numbers of XML files having issues, it will be a tiresome task to get rid of the error. So in order to tackle this situation, we have some methods to quickly find out the file and rectify the issue.
1. Open Every XML file
One of the methods is manually opening every XML file without scanning or running. This is helpful because when you open a file Android Studio will detect the errors if any and underline the codes where the issue has crept in. This way you can quickly identify where is the problem and resolve it without having many headaches.
2. Run a Stacktrace
It’s obvious that if you have a big project, it will be a nightmare to check each and every XML file. So one of the best workarounds for this error is to open the Android Studio Terminal and run a Stacktrace. This will show you which file is causing the issue. To do a stacktrace run the following command in the Android Studio terminal.
gradlew build —stacktrace
3. Undo the Changes
This is another hack by which you can get rid of the Android resource linking failed error. Undoing the last changes may sometimes help you quickly. In most times this issue will arise when you are halfway through a development project. This means that one of the recent changes is responsible for generating such an error. So just reverting the last commits can definitely help you out to tackle this situation.
For this to do, press CTRL + Z to go a revert a single change. Likewise, debug the code after each undo and you will quickly find out where is the error. Once you find it out, you can correct it with ease as it’s not kind of a big deal.
Conclusion
Hopefully, by now, you have learned a few workarounds to troubleshoot the android resource linking failed issue and get rid of that with ease.
If you find this article useful, feel free to share it and spread the knowledge.
Источник
Android resource linking failed : Unity Error :unexpected element found in #1551
Comments
AliAhmadUnityDev commented Jan 13, 2021
Step 0: Are you in the right place?
For general technical questions, or help with project-specific issues like setting up ads in
your app, reach out to our support team on the
Developer Forum.
For assistance with your AdMob account, reach out to
AdMob Support.
For feedback on our documentation,
send your feedback by pressing the Send Feedback button at the top right of the
documentation page you are on.
For issues related to the code in this repository, continue filing this GitHub issue.
Once you’ve read this section and determined that your issue is appropriate for
this repository, please delete this section.
[REQUIRED] Step 1: Describe your environment
- Unity version: 2018.4.8 LTS
- Google Mobile Ads Unity plugin version: 5.4.0
- Platform: Android
- Platform OS version: All Android versions
- Any specific devices issue occurs on: Occurs On all devices
- Mediation ad networks used, and their versions: No
[REQUIRED] Step 2: Describe the problem
Android resource linking failed : Unity Error :unexpected element found in
-1
I am using getting this error when building with Admob (Google Mobile Ads SDK for unity) and Facebook Audience Network SDK for unity. If I use one of these separately in project then there comes no error but if I use both of these, then I start getting this error on build. However I have tested and can confirm that this error doesn’t appears on Unity 2020 versions but it comes in all Unity 2018 as well as 2019 versions. Please help me out to solve this error.
I can share the Project complete file if required but it can be easily reproduced by adding Admob unity SDK and Facebook audience network unity sdk and building the project for Android platform.
I am Using:
Unity Editor 2018.4.30 LTS version
Admob SDK (Google Mobile Ads SDK) version 5.4.0
FAcebook Audience Network version 6.2.0
Scripting Backend: IL2CPP
JDK: jdk1.8.0_271
Steps to reproduce:
This error can be reproduced By importing GoogleMobileAds SDK (5.4.0) and Audience Netwrok SDK (6.2.0) in a project in unity having editor versions 2018 or 2019.
Relevant Code:
`CommandInvokationFailure: Gradle build failed.
C:\Program Files\Java\jdk1.8.0_271\bin\java.exe -classpath «C:\Program Files\UnityInstallFolder\Unity_2018.4.30\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-5.1.1.jar» org.gradle.launcher.GradleMain «-Dorg.gradle.jvmargs=-Xmx4096m» «assembleRelease»
FAILURE: Build failed with an exception.
- What went wrong:
Execution failed for task ‘:processReleaseResources’.
Android resource linking failed
D:\Projects\ADS Packages\ReportingProjectSample\Temp\gradleOut\build\intermediates\merged_manifests\release\AndroidManifest.xml:36: AAPT: error: unexpected element found in .
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.
BUILD FAILED in 6s
]
stdout[
Task :preBuild UP-TO-DATE
Task :GoogleMobileAdsPlugin.androidlib:preBuild UP-TO-DATE
Task :GoogleMobileAdsPlugin.androidlib:preReleaseBuild UP-TO-DATE
Task :GoogleMobileAdsPlugin.androidlib:checkReleaseManifest
Task :GoogleMobileAdsPlugin.androidlib:processReleaseManifest
Task :preReleaseBuild UP-TO-DATE
Task :GoogleMobileAdsPlugin.androidlib:compileReleaseAidl NO-SOURCE
Task :compileReleaseAidl NO-SOURCE
Task :GoogleMobileAdsPlugin.androidlib:packageReleaseRenderscript NO-SOURCE
Task :compileReleaseRenderscript NO-SOURCE
Task :checkReleaseManifest UP-TO-DATE
Task :generateReleaseBuildConfig UP-TO-DATE
Task :prepareLintJar UP-TO-DATE
Task :generateReleaseSources UP-TO-DATE
Task :GoogleMobileAdsPlugin.androidlib:compileReleaseRenderscript NO-SOURCE
Task :GoogleMobileAdsPlugin.androidlib:generateReleaseBuildConfig
Task :GoogleMobileAdsPlugin.androidlib:generateReleaseResValues
Task :GoogleMobileAdsPlugin.androidlib:generateReleaseResources
Task :GoogleMobileAdsPlugin.androidlib:packageReleaseResources
Task :GoogleMobileAdsPlugin.androidlib:generateReleaseRFile
Task :GoogleMobileAdsPlugin.androidlib:prepareLintJar UP-TO-DATE
Task :GoogleMobileAdsPlugin.androidlib:generateReleaseSources
Task :GoogleMobileAdsPlugin.androidlib:javaPreCompileRelease
Task :GoogleMobileAdsPlugin.androidlib:compileReleaseJavaWithJavac
Task :GoogleMobileAdsPlugin.androidlib:bundleLibCompileRelease
Task :javaPreCompileRelease UP-TO-DATE
Task :mainApkListPersistenceRelease UP-TO-DATE
Task :generateReleaseResValues UP-TO-DATE
Task :generateReleaseResources UP-TO-DATE
Task :mergeReleaseResources
Task :createReleaseCompatibleScreenManifests
Task :processReleaseManifest
Task :processReleaseResources FAILED
Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use ‘—warning-mode all’ to show the individual deprecation warnings.
See https://docs.gradle.org/5.1.1/userguide/command_line_interface.html#sec:command_line_warnings
21 actionable tasks: 13 executed, 8 up-to-date
]
exit code: 1
UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at :0)
UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at :0)
UnityEditor.Android.Command.Run (System.String command, System.String args, System.String workingdir, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at :0)
UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action 1[T] progress, System.String error) (at :0) UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String task, System.Action 1[T] progress) (at :0)
Rethrow as GradleInvokationException: Gradle build failed
UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String task, System.Action 1[T] progress) (at :0) UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at :0) UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at :0) Rethrow as BuildFailedException: Exception of type ‘UnityEditor.Build.BuildFailedException’ was thrown. UnityEditor.Android.PostProcessor.CancelPostProcess.AbortBuild (System.String title, System.String message, System.Exception ex) (at :0) UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at :0) UnityEditor.Android.PostProcessAndroidPlayer.PostProcess (UnityEditor.BuildTarget target, System.String stagingAreaData, System.String stagingArea, System.String playerPackage, System.String installPath, System.String companyName, System.String productName, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at :0) UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at :0) UnityEditor.PostprocessBuildPlayer.Postprocess (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget target, System.String installPath, System.String companyName, System.String productName, System.Int32 width, System.Int32 height, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/PostprocessBuildPlayer.cs:288) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr) (at C:/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:179)
The text was updated successfully, but these errors were encountered:
Источник