Gradle build fail with adressables

I’m having a huge issue. I simply can’t build my game anymore on Android. It says there is an error with AAPT2 but it doesn’t make much sense to me. And it seems it manage to make the build if the addressables build it empty.

This is quite important for me since I have to ship my game in 6 days !

Anybody knows what the hell could be happening?

i forgot to say, I’m working on 2020.1.6
And exporting the project to android Studio doesn’t work either.

ok, after a lot of tries, it seems the build crashes if there are too many bundles in the streaming assets folder…
I had to pack the bundles to “pack together” or “by label” to make it work.
The problem is that now, the ingame loadings are super slow, and the RAM used is much higher. So I now expect the game to crash on low-end devices… :frowning:

1 Like

I have the same problem, but everything happens when I put GoogleMobileAds, (well, it also happens when I put vuforia, but I already solved that) apparently it is more difficult to compile in UNITY than to carry out the same project itself. I am not a programmer, but with all the Unity errors, apparently that I am a simple novice who only knows how to put “Hello world” I solve or try to solve the Unity problems.

hello, is there a workaround now ?

1 Like

link to the issue : Unity Issue Tracker - [Android] Build fails when there are 680 or more files in the Streaming Assets folder

This is a compatible bug between com.android.tools.build:gradle:3.6.0 and unity 2020, Please do following step to resolve:

1, Edit → Player Setting → Publishing Settings, click “Custom Base Gradle Template” blew the Build section.

2, You will find a “Assets\Plugins\Android\baseProjectTemplate.gradle” file was generated, open it by text editor.

3, change
“classpath ‘com.android.tools.build:gradle:3.6.0’”
into
“classpath ‘com.android.tools.build:gradle:3.4.0’”

Build again, and don’t forget to add it to your CVS.

If you get solved and like this solution, please do me a favor to mark a star for this repo:
https://github.com/yasio/yasio

This repo’s author find this solution and he told me.

7 Likes

I had a similar issue when builds started failing after integrating GoogleMobileAds and came across this thread. Solved it by enabling Custom Gradle Properties in Publishing Settings, and adding android.useAndroidX=true and android.enableJetifier=true to the settings file. Also enabled JetBrains via the External Dependency Manager → Android Resolver → Settings but that didn’t work on its own without the properties file change

Solved Thank you jerry_tianzhizhi

i am still facing in unity 2020.2.7 with grale 5.6.4

the option ‘android.enableR8’ is deprecated and should not be used anymore. It will be removed in a future version of the Android Gradle plugin, and will no longer allow you to disable R8

Set to minimum API level to at least 21. It worked for me.

On Unity 2020.3.19 I’ve got the minimum api set to 23 and I’m getting this error.

1 Like

Same thing, 2020.3.7 and minimum API set to 23

1 Like

Changing both the minimum and target API’s to level 29 (which I believe is what’s installed on my Quest 2, for which this build is intended) – I would get the following error:

With Publish Settings>>Minify>>Use R8 unticked, I got this error:

If it was ticked, I got this error:

So, ticking the box is deprecated and not ticking the box is deprecated??!

I reinstalled Android SDK 12 (API 31) despite not even targeting that api, yet the build would still fail with multiple complaints about it being corrupted. For whatever reason, the dx.bat file was missing from that API installation, as the above error messages say. So, I fabricated it based on the d8.bat file – making the couple of changes that are different between the d8.bat and dx.bat in other API installations.

Since the dx.jar file is also missing the build will still fail…

No idea why Android Studio isn’t installing the dx.jar and dx.bat files for this particular api. Searching the internet I found somebody solved this by copying the dx.dar file from their API 30 installation, which I then tried.
…and it worked!

:smile:

Hey!! Thnx for the Solution…it works

2 Likes

Hello!

In case there is somebody with this problem and mentioned solution did not work for him, I had a similar error during android build using 2020.3.26 and in my case it was caused by my antivirus blocking some android SDK files for some reason. I am using Avast but you might have the same problem with other antivirus as well.

I have temporarily disabled my antivirus before build and it built without problem, you can try it as well.