-
Notifications
You must be signed in to change notification settings - Fork 428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] Gradle build fails on Unity 2021 when custom gradle templates are enabled #1205
Comments
Hi @kashif789us, Thanks for reporting this issue. I was also able to replicate this issue using the quickstart with the same Unity version. Here is the error message I got for reference: I'll be marking this as a bug for now. Let me discuss this with the team, and we'll get back to you once we have updates. |
Unity editor version: 2021.2.0f1 Hello, I am getting the same issues on a slightly different editor and Firebase version. Sample failure message:
|
Hi all, Thanks to @deetmo, this appears to be a regression from the Unity side. Their fix has been integrated to If you are experiencing this issue, here are some workarounds
It would be rather challenging to provide a patch for this in EDm4U but we'll see what we can do. |
Problem Fixed here : https://www.codeprofessionally.com/2022/03/gradle-build-failed-unity.html |
i can fix this error send message on facebook : https://www.facebook.com/Code-Prof-110511874050372 |
@CodeProf14 I tried that also, but it still doesn't work! |
Let me know if u find any solution |
Same here after trying to upgrade to Unity 2022 |
If you are still having this issue and can't update Unity, place this script into an Editor folder: using System.IO;
using UnityEditor;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
using UnityEngine;
/// <summary>
/// Fix for https://issuetracker.unity3d.com/issues/android-template-variable-star-star-dir-unityproject-star-star-is-not-properly-substituted-when-exporting-a-gradle-project
/// This bug is fixed in Unity 2021.2.8. This script can be removed when updating Unity.
/// </summary>
class FixGradleTemplateBug : IPreprocessBuildWithReport, IPostprocessBuildWithReport
{
public int callbackOrder { get { return 0; } }
private const string GradleMainTemplatePath = "Assets/Plugins/Android/mainTemplate.gradle";
private string originalMainTemplateContents = null;
public void OnPreprocessBuild(BuildReport report)
{
originalMainTemplateContents = null;
if (File.Exists(GradleMainTemplatePath))
{
originalMainTemplateContents = File.ReadAllText(GradleMainTemplatePath);
string projectDir = Path.GetDirectoryName(Application.dataPath);
Debug.Log($"To fix a bug, replacing **DIR_UNITYPROJECT** with \"{projectDir}\" in the gradle template file \"{GradleMainTemplatePath}\"."
" This fix can be removed after updating to Unity 2021.2.8 or later");
string fixedContents = originalMainTemplateContents.Replace("**DIR_UNITYPROJECT**", projectDir);
File.WriteAllText(GradleMainTemplatePath, fixedContents);
}
}
public void OnPostprocessBuild(BuildReport report)
{
if (!string.IsNullOrEmpty(originalMainTemplateContents))
{
File.WriteAllText(GradleMainTemplatePath, originalMainTemplateContents);
originalMainTemplateContents = null;
}
}
} |
Same here after migration from 2021.3.16 to 2022.3.2 |
I encountered a similar issue with Unity Editor version 2021.3.9f1 and all other 2021 Unity versions while building the APK. However, after some troubleshooting, I found a workaround that might be helpful to others facing the same problem. Solution:
I hope this information is helpful for others facing the same problem. Please let me know if you need any further details. |
I got error while build in Unity android port (and two more similar errors for files: firebase-messaging-unity-11.6.0.pom and google-signin-support-1.0.4.pom): Could not determine the dependencies of task ':launcher:lintVitalRelease'.
But the problem is that I have these files! They are located along one of the paths from the search list. in the generated directory: Why am I getting an error? What could be the reason? |
[REQUIRED] Please fill in the following fields:
[REQUIRED] Please describe the issue here:
My APK fails during building gradle with following error:
Steps to reproduce:
Have you been able to reproduce this issue with just the Firebase Unity quickstarts (this GitHub project)?
What's the issue repro rate?
Yes, 100% when I enable mainTemplate.gradle and disable Auto Resolution in Android Resolver Settings.
What happened? How can we make the problem occur?
It builds fine If I don't enable gradle scripts and enable Auto Resolution.
It is also building without any problem on older Unity versions with custom gradle files.
The text was updated successfully, but these errors were encountered: