Long cannot fit in uint

Unity Version: 2021.3.12f1.
Target SDK Version: 33

I get error on building Android App Bundle:

Long cannot fit in uint

This error is caused by zipflinger’s exception (new ZIP library by Google).

Error

Caused by: java.lang.IllegalStateException: Long cannot fit in uint at com.android.zipflinger.Ints.longToUint(Ints.java:31) at com.android.zipflinger.CentralDirectoryRecord.write(CentralDirectoryRecord.java:78) at com.android.zipflinger.CentralDirectory.write(CentralDirectory.java:114) at com.android.zipflinger.ZipArchive.writeArchive(ZipArchive.java:194) at com.android.zipflinger.ZipArchive.closeWithInfo(ZipArchive.java:166) at com.android.zipflinger.ZipArchive.close(ZipArchive.java:155)

Take it up with zipflinger, then. It’s true. You can’t stuff 64 bits into a 32 bit variable.

Are there constraints for Android or what? Does Android use FAT32? If not, why it cannot fit more than 4GB?

File length limits would depend on the filesystem. Most uSD cards will use FAT32. But you’re jumping to the conclusion that the error came from exceeding a file length. It seems something is calling the API with the wrong kind of variable, which could be for any number of reasons that are internal to that library or the function calling it.

Did this error occur on other versions of Unity? Are you calling the zip API yourself?

No, I use Play Asset Delivery for building Android App Bundle. So, it happens during building.

The error is a runtime exception. It’s not necessary a bug. Is it possible that your apk file gets larger than 4GB?
Android apk file cannot be larger than 4GB because it’s a zip archive and that is a limitation of zip (the simple one, there are extended versions that can be larger, but I don’t know if Android supports those, likely no due to tooling not supporting it).