build error

i have upgraded unity from unity 2019 to latest. Suddenly, i cant build my project. There is an error
" mainTemplate.gradle file is using the old aaptOptions noCompress property definition which does not include types defined by unityStreamingAssets constant."
There is only one thread regarding this issue, but i have not found any solution. if someone has any knowledge about this issue. plz help.Thanks.

1 Like

For Unity 2021.1 and Android 10 I use mainTemplate.gradle for my project and here I changed to this:

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

from this:

aaptOptions {
        ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
    }

Or you can just delete current .gradle file and Unity regenerates it again with correct settings.

For anyone still having this issue when upgrading from 2019.x to 2020.3. I found mainTemplate.gradle in the following folder:

“\Unity\2020.3.1f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\GradleTemplates”. Settings were as described in the above answers which was confusing as I was still getting the build error.

I then checked my project folder for mainTemplate.gradle and found a copy hiding here:

{ProjectName}\Assets\Plugins\Android\

Once I removed the copy here the build then worked as expected.

Problem fixed here : mainTemplate.gradle file is using the old aaptoptions - YouTube

Try to delete the mainTemplate.gradle and let Unity create it again by checking the checkmark for the mainTemplate in the Android Settings.

switched to 2020.3.0f1 here, its a pain to build for Android :

  • What went wrong:
    Execution failed for task ‘:launcher:processReleaseResources’.

A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
AAPT2 aapt2-3.6.0-6040484-windows Daemon #0: Unexpected error during link, attempting to stop daemon.
This should not happen under normal circumstances, please file an issue if it does.

I tried to fix the issue by following the instructions above only to get another issue. I tried deleting all the manifests, unticking and reticking the android selections but still the below error is repeated.188486-error-resourcestyle.png

Any help would be welcome.

Thaks this worked for me @makaka-org