Android Build error : could not find file \Assets\Plugins\Android\mainTemplate.gradle

When I build on android I get this message

8657892--1165713--upload_2022-12-13_14-53-31.png

I do not have this file in my project folder and I never did.
I did a git compare with previous revisions and I don’t see the culprit.
I tried many things like deleting the Library folder, Reimporting, Force resolving.

The only way to build the project is by using the Google menu
8657892--1165722--upload_2022-12-13_14-55-35.png

Is there something I can do to make the build work again as normally?

Looks like you are using some plugin for build. Have you tried building app bundle via Unity Buil Settings window?

That’s my problem, when I use the unity build settings window it doesn’t work anymore

Ah, the error comes from IPostGenerateGradleAndroidProject callback. If it’s not something you made, then one of your plugins has it and it fails. Given that it work from this custom menu, but not from Unity, likely it’s the same plugin and it does temporary setup the template for the build and clears it afterwards. When building via Unity, nothing setups the template, but callback still runs and chokes on it.

Thanks for the reply @Aurimas-Cernius when I click on the “Google” menu it links to

I’ll check why I use that and try to remove it and see how it goes

@Aurimas-Cernius I deleted com.google.android.appbundle from /Assets/GooglePlayPlugins but it didn’t work out. I believe it’s something else.
when I compare with a previous working revision, it seems that I deleted theses files because they were duplicated.
8659383--1165998--upload_2022-12-13_22-10-39.png

I think it was a library update, I reverted manifest.json and deleted some dll, /Library, and it seems to work again

I found the culprit @Aurimas-Cernius , it’s unity mediation, I was in 1.0.4 and updated it to 1.0.5 and it prevent me from building to android. Is this bug already reported to the mediation team ?

I believe it’s that line that causes it from the changelog
“Android: Added the android.enableDexingArtifactTransform flag setting it to false in the gradle.properties file if the mainTemplate.gradle file is not being used, this can be toggled off in settings.”

@Aurimas-Cernius is there a good practice to report this kind of bug to the team or using the forum like I did is ok ?

Best practice is to create a small project that showcases the problem and submit a bug via Unity Editor.