I’m currently working on Gradle template workflow to generate a custom launcher gradle file from launcherTemplate.gradle file.
However, even I put the launcherTemplate.gradle file in “Assets/Plugins/Android” directory, it isn’t copied and parsed into “[AndroidBuildFolder]/launcher/build.gradle” file which makes the process much harder to maintain.
Compared to this template, mainTemplate.gradle and settingsTemplate.gradle behave as expected. They are copied from the “Assets/Plugins/Android” directory under “[AndroidBuildFolder]” directory so I can make use of them.
Is there any way I can use a custom launcher gradle file and replace it with the default launcher gradle file? Or do you have a plan to make the launcherTemplate.gradle file behave as expected as mainTemplate and settingTemplate? When will it be if it is planned already?
Thanks for reading the post!
I’d expect to have the answer soon
It would be appreciated if someone has the same problem and share any solution if you have any of them.
Same, my custom mainTemplate.gradle creates gradle compile errors for me starting with 2019.3.0f1. Due to the fact I need to add my gradle changes to the app / launcher project instead. However adding launcherTemplate.gradle to my project isn’t getting picked up.
I tried Unity 2019.3.0f1 AND 2020.1.0a14 it isn’t exporting it nor using it when doing a build. In addition to the launcherTemplate.gradle file I tried to add baseProjectTemplate.gradle to “Assets/Plugins/Android” but no go.
When going to “Player Settings” > “Publishing Settings” > Build I see “Custom Gradle Template” as however just like older version of Unity it just states mainTemplate.gradle. I suspect Unity hasn’t completed this part in the beta and it can’t be enabled yet.
I see the following files exist in Unity itself but it always seems to the built in one instead of the project one.
I have already looked over the current documentation for this and it doesn’t provide any details on how to enable these new .gradle files for a project.
There is also a post about the feature that you can try following up as well under.
Just wanted to say I’m having the same problem. OneSignal for Unity requires a manual override to the mainTemplate.gradle file, but it looks like this needs to happen in the launcherTemplate.gradle file now (as far as I understand). Hope this gets supported soon.
I need to be able to customize the filename of the resulting .apk file based on environment variables that exist on the build server at build time. Up through Unity 2018 I could have something like this in defaultConfig of my mainTemplate.gradle:
But now in Unity 2019(.3) the above no longer works. I get build errors saying: Could not get unknown property ‘applicationVariants’ for DefaultConfig_Decorated. By going back over the Unity documentation for gradle I surmise what would previously have been a single monolithic template.gradle file has now been broken up into multiple templates, each with their own role in the build process. Judging from the explanations, what I’m trying to do (walking through applicationVariants and setting the outputFileName) does not belong in mainTemplate.gradle anymore and should be in launcherTemplate.gradle.
But I have no idea what else I need to put in that file to make it “valid”!
I have to modify the gradle file for the launcher but my launcherTemplate.gradle file is not used.
However, the mainTemplate.gradle file is used for the library project.
I’m experiencing this issue under Unity2019.3.3
Seriously, this seem like a bug. Now I think I can’t use cloud build because I have migrate project to 2020. And why no unity people ever look into this bug since 2019???
It seem this feature is available in latest beta version
Android: Allow to overwrite gradle.properties file, as well as main and launcher manifests, base, launcher and main gradle templates. Default templates can be added to project by enabling checkboxes in Player Settings > Publishing Settings.