Gradle Build Error-gradle7.2 Error . Convocation Failed

Hi All

I am trying to make my build in unity 2021.3,42 f1, When i am build the same project in ios it works perfectly. When i change it to android build it says the error. Gradle build error.

Blockquote
FILE_STRING = Default
AMPLITUDE_TOKEN_REDBUCKET_DEV = U4PSN7S7PuYVRODivvdcFwbu8R6IHGqa
CHROME_CRASHPAD_PIPE_NAME = \.\pipe\crashpad_284_PUMNFFCGADNNXBKM
PROCESSOR_LEVEL = 6
JAVA_TOOL_OPTIONS = -Dfile.encoding=UTF-8
CommonProgramFiles = C:\Program Files\Common Files
JAVA_HOME = C:\Program Files\Unity\Hub\Editor\2022.3.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK
USERDOMAIN_ROAMINGPROFILE = DESKTOP-8EGCT80
TEMP = C:\Users\ADMIN\AppData\Local\Temp
ProgramFiles = C:\Program Files
CommonProgramW6432 = C:\Program Files\Common Files
AMPLITUDE_TOKEN_YELLOWBUCKET_DEV = wKi8foVigDditGFvmZewRFWsEbX9Y0YO
AMPLITUDE_API_KEY_GREENBUCKET_DEV = 3ded2a762163603391a425f688f990c8
AMPLITUDE_API_KEY_REDBUCKET_PROD = ca12bb461ea96f9bdf5df4ded7d52994
HOMEDRIVE = C:
AMPLITUDE_API_KEY_STAGING = 83ee04fccc67e4fcc7dd527c4c6f1e21
USERNAME = ADMIN
OneDrive = C:\Users\ADMIN\OneDrive
AMPLITUDE_API_KEY_YELLOWBUCKET_PROD = e03a9bbe92dc38a88cdb068d24c65b46
PATHEXT = .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
AMPLITUDE_TOKEN_REDBUCKET_PROD = jTIgKs5KTZOjiqEEVdZFbgo_VRhABduL
__PSLockDownPolicy = 0
NUMBER_OF_PROCESSORS = 8
AMPLITUDE_TOKEN_GREENBUCKET_DEV = 84H2gMm_FJzhr3mBaX1lM1JVukmCM7d9
AMPLITUDE_DEPLOYMENT_KEY_RED_BUCKET_DEV = client-wbjHYrmeSR87GmWOE7LDpf7sUySOIKHm
AMPLITUDE_API_KEY_GREENBUCKET_PROD = c86fea37a9e1d3f0878b96e15b111c7c
ComSpec = C:\WINDOWS\system32\cmd.exe
ORIGINAL_XDG_CURRENT_DESKTOP = undefined
PROCESSOR_REVISION = 2a07
AMPLITUDE_DEPLOYMENT_KEY_RED_BUCKET_PROD = client-zH8Y7OK1i331EKuG77C6UxN8ygcM6LzS
TMP = C:\Users\ADMIN\AppData\Local\Temp
SystemDrive = C:
AMPLITUDE_API_KEY = 28f3cae0b33b8b3702120c9ed1a935aa
FPS_BROWSER_APP_PROFILE_STRING = Internet Explorer
OneDriveConsumer = C:\Users\ADMIN\OneDrive
SENTRY_ACCESS_TOKEN = 3df78d9e53f8456aa90fbae044ce1a6261421ab1d0014674bc2e933477289017
APPDATA = C:\Users\ADMIN\AppData\Roaming
Path = C:\Program Files\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Program Files\PuTTY;C:\Users\ADMIN\AppData\Local\Programs\Python\Python312\Scripts;C:\Users\ADMIN\AppData\Local\Programs\Python\Python312;C:\Users\ADMIN\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\Scripts
PSModulePath = C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules;C:\Program Files (x86)\AWS Tools\PowerShell
LOCALAPPDATA = C:\Users\ADMIN\AppData\Local
USERPROFILE = C:\Users\ADMIN
WOOTRIC_CLIENT_TOKEN = NPS-aa8be4c3

stderr[
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8

FAILURE: Build failed with an exception.

  • Where:
    Build file ‘D:\FooyaAndroid06-08-24\fooyaiostoandroidbuilderror3\fooyaandtoios\Library\Bee\Android\Prj\Mono2x\Gradle\unityLibrary\build.gradle’ line: 40

  • What went wrong:
    Could not compile build file ‘D:\FooyaAndroid06-08-24\fooyaiostoandroidbuilderror3\fooyaandtoios\Library\Bee\Android\Prj\Mono2x\Gradle\unityLibrary\build.gradle’.

startup failed:
build file ‘D:\FooyaAndroid06-08-24\fooyaiostoandroidbuilderror3\fooyaandtoios\Library\Bee\Android\Prj\Mono2x\Gradle\unityLibrary\build.gradle’: 40: Unexpected input: ‘{’ @ line 40, column 9.
android {
^

1 error

  • 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 59s
]
stdout[
Starting a Gradle Daemon, 1 incompatible Daemon could not be reused, use --status for details
]
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.Action1[T] progress, System.String error) (at <c3a7a35f684a4e72b8a6533d8c702ad7>:0) UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, Unity.Android.Gradle.AndroidGradle androidGradle, System.String workingdir, System.String task, System.Action1[T] progress) (at :0)
Rethrow as GradleInvokationException: Gradle build failed
UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, Unity.Android.Gradle.AndroidGradle androidGradle, 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)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

I am receiving the error. I have installed 2022.3.41f1… same error happesn. I have setup the android version to 33 . and make the build the same error happens. and also i have downloaded the all the old version 2021.3.27 and other versions. also . but the same error happens. I have firebase in my project. I have removed it also… but the error continues… which build is the correct build . many peoples are facing this problem. what i have to do. is there any official bug fix for this project. . could anyone help me to solve this problem.

thanks you

Hey @AlexanderL1! Do you have a custom mainTemplate.gradle file inside the Plugins/Android/ directory? If so, could you share it here?

Thanks!

@manugil thanks for you reply. This is the mainTemplate.gradle…

// Android Resolver Repos Start
([rootProject] + (rootProject.subprojects as List)).each { project →
project.repositories {
def unityProjectPath = /file:///**DIR_UNITYPROJECT**/.replace(“\”, “/”)
maven {
url “https://maven.google.com
}
maven {
url (unityProjectPath + “/Assets/GeneratedLocalRepo/Firebase/m2repository”) // Assets/Firebase/Editor/AppDependencies.xml:22, Assets/Firebase/Editor/AuthDependencies.xml:20
}
mavenLocal()
mavenCentral()
}

I have tried all the options… but it is not working. i have firebase in myproject. even i have remove itself. the error comes.

kindly help me for successful completion of apk…
}
// Android Resolver Repos End

apply plugin: ‘com.android.library’

// Android Resolver Dependencies Start
implementation ‘com.google.android.gms:play-services-base:17.6.0’ // Assets/Firebase/Editor/AppDependencies.xml:17
implementation ‘com.google.firebase:firebase-analytics:19.0.0’ // Assets/Firebase/Editor/AuthDependencies.xml:15
implementation ‘com.google.firebase:firebase-app-unity:8.0.0’ // Assets/Firebase/Editor/AppDependencies.xml:22
implementation ‘com.google.firebase:firebase-auth:21.0.1’ // Assets/Firebase/Editor/AuthDependencies.xml:13
implementation ‘com.google.firebase:firebase-auth-unity:8.0.0’ // Assets/Firebase/Editor/AuthDependencies.xml:20
implementation ‘com.google.firebase:firebase-common:20.0.0’ // Assets/Firebase/Editor/AppDependencies.xml:13
// Android Resolver Dependencies End

// Android Resolver Exclusions Start
android {
packagingOptions {
exclude (‘/lib/armeabi/’ + '’)
exclude (‘/lib/mips/’ + '’)
exclude (‘/lib/mips64/’ + '’)
exclude (‘/lib/x86/’ + '’)
exclude (‘/lib/x86_64/’ + '’)
}
}
// Android Resolver Exclusions End

android {
compileSdkVersion APIVERSION
buildToolsVersion ‘BUILDTOOLS

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

defaultConfig {
    minSdkVersion **MINSDKVERSION**
    targetSdkVersion **TARGETSDKVERSION**
    ndk {
        abiFilters **ABIFILTERS**
    }
    versionCode **VERSIONCODE**
    versionName '**VERSIONNAME**'
    consumerProguardFiles 'proguard-unity.txt'**USER_PROGUARD**
}

lintOptions {
    abortOnError false
}

aaptOptions {
    noCompress = **BUILTIN_NOCOMPRESS** + unityStreamingAssets.tokenize(', ')
    ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
}**PACKAGING_OPTIONS**

// Android Resolver Properties Start
android.useAndroidX=true
android.enableJetifier=true
// Android Resolver Properties End

// Additional properties
in that addorg.gradle.jvmargs=-Xmx**JVM_HEAP_SIZE**M
org.gradle.parallel=true
unityStreamingAssets=**STREAMING_ASSETS**

// Enable R8

// android.enableR8=false
}

The error suggests that the formatting is wrong on your mainTemplate.gradle file, but it’s hard to understnand from the text you have copied. Could you drag and drop the mainTemplate.gradle file into the forum, it should automatically attach it to your comment.

Another option to fix it would be to just entirely remove the mainTemplate.gradle file and re-do it again. This can be done by backing up your current mainTemplate.gradle file and then going to Player Settings > Publishing > Custom Main Template Gradle and check the box again.

Thanks For you reply. i have attached this mainTemplate.gradle file… [
mainTemplate2.txt (2.8 KB)
](https://)

i am trying for past 15 days . installed many versions… kindly help me to solved the version…