Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Build fails with "Long cannot fit in uint"

Discussion in 'Android' started by TurgutHakki, Jul 15, 2021.

  1. TurgutHakki

    TurgutHakki

    Joined:
    Jun 15, 2017
    Posts:
    33
    We have a project that we are trying to port to an android based platform.

    Build fails with following message. I tried to run the build command with --debug, --info, and --stacktrace options but it reveals no additional information. Empty unity project can be built.

    Has anyone encountered this before?

    * What went wrong:
    Execution failed for task ':launcher:packageDebug'.
    > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
    > Long cannot fit in uint
     
  2. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,663
    A guess, but probably some number in your gradle file is negative. Check the contents of gradle files
     
  3. TurgutHakki

    TurgutHakki

    Joined:
    Jun 15, 2017
    Posts:
    33
    No negative values present in *.gradle files of exported project
     
  4. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,663
    Can you attach your gradle files here?
     
  5. TurgutHakki

    TurgutHakki

    Joined:
    Jun 15, 2017
    Posts:
    33
    Appearanly it's something to to with zip while creating apk

    Code (CSharp):
    1. Caused by: java.lang.IllegalStateException: Long cannot fit in uint
    2.         at com.android.zipflinger.Ints.longToUint(Ints.java:31)
    3.         at com.android.zipflinger.CentralDirectoryRecord.write(CentralDirectoryRecord.java:78)
    4.         at com.android.zipflinger.CentralDirectory.write(CentralDirectory.java:114)
    5.         at com.android.zipflinger.ZipArchive.writeArchive(ZipArchive.java:194)
    6.         at com.android.zipflinger.ZipArchive.closeWithInfo(ZipArchive.java:166)
    7.         at com.android.signflinger.SignedApk.finishV2(SignedApk.java:184)
    8.         at com.android.signflinger.SignedApk.close(SignedApk.java:158)
    9.         at com.android.builder.internal.packaging.SynchronizedArchive.close(SynchronizedArchive.kt:46)
    10.         at com.android.builder.internal.packaging.ApkFlinger.close(ApkFlinger.kt:216)
    11.         at com.google.common.io.Closer.close(Closer.java:214)
    12.         at com.android.builder.internal.packaging.IncrementalPackager.close(IncrementalPackager.java:406)
    13.         at com.android.build.gradle.tasks.PackageAndroidArtifact.doTask(PackageAndroidArtifact.java:683)
    14.         at com.android.build.gradle.tasks.PackageAndroidArtifact.access$300(PackageAndroidArtifact.java:136)
    15.         at com.android.build.gradle.tasks.PackageAndroidArtifact$IncrementalSplitterRunnable.run(PackageAndroidArtifact.java:828)
    16.         at com.android.build.gradle.internal.tasks.Workers$ActionFacade.run(Workers.kt:348)
    17.         at org.gradle.workers.internal.AdapterWorkAction.execute(AdapterWorkAction.java:50)
    18.         at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:47)
    19.         at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1$1.create(NoIsolationWorkerFactory.java:65)
    20.         at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1$1.create(NoIsolationWorkerFactory.java:61)
    21.         at org.gradle.internal.classloader.ClassLoaderUtils.executeInClassloader(ClassLoaderUtils.java:98)
    22.         at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.execute(NoIsolationWorkerFactory.java:61)
    23.         at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:44)
    24.         at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:41)
    25.         at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:416)
    26.         at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:406)
    27.         at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
    28.         at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
    29.         at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
    30.         at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:102)
    31.         at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
    32.         at org.gradle.workers.internal.AbstractWorker.executeWrappedInBuildOperation(AbstractWorker.java:41)
    33.         at org.gradle.workers.internal.NoIsolationWorkerFactory$1.execute(NoIsolationWorkerFactory.java:56)
    34.         at org.gradle.workers.internal.DefaultWorkerExecutor$3.call(DefaultWorkerExecutor.java:215)
    35.         at org.gradle.workers.internal.DefaultWorkerExecutor$3.call(DefaultWorkerExecutor.java:210)
    36.         at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runExecution(DefaultConditionalExecutionQueue.java:215)
    37.         at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runBatch(DefaultConditionalExecutionQueue.java:164)
    38.         at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.run(DefaultConditionalExecutionQueue.java:131)
     
  6. TurgutHakki

    TurgutHakki

    Joined:
    Jun 15, 2017
    Posts:
    33
    Here are gradle files along with the editor.log
     

    Attached Files:

  7. TurgutHakki

    TurgutHakki

    Joined:
    Jun 15, 2017
    Posts:
    33
    Adding
    Code (CSharp):
    1. android.useNewApkCreator = false
    line to gradle.properties seems to have solved the problem but it led to another. It might be about the apk size (should be around 6GB)
     
  8. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,663
    You won't able to upload such huge APK, I think the max size is something like 150 MB + additional data can be stored in asset packs (upcoming feature in Unity)
     
  9. TurgutHakki

    TurgutHakki

    Joined:
    Jun 15, 2017
    Posts:
    33
    It was about the APK size limit. (Which is 4GB apparently) when I reduced the size of the assets, It builds
     
  10. TurgutHakki

    TurgutHakki

    Joined:
    Jun 15, 2017
    Posts:
    33
    It's for an android based console platform not google play. :)
     
    Tomas1856 likes this.
  11. trooper

    trooper

    Joined:
    Aug 21, 2009
    Posts:
    746
    I have this similar error after upgrading from a working build on 2020.3.33f1 to 2021.3.0f1

    I've exported the project and gone through all gradle and xml files in the project and there are no negative numbers. Is there another reason this message can appear?

    * What went wrong:
    Execution failed for task ':launcher:assetPackDebugPreBundleTask'.
    > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
    > Long cannot fit in uint
     
  12. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,663
    For the person above, the issue was - too big apk, maybe the same case is for you?
     
  13. trooper

    trooper

    Joined:
    Aug 21, 2009
    Posts:
    746
    I've attempted using aab, apk with and without split binary, building api API 31, 30, 29.

    I've removed all my overriden gradle files and built a brand new project (works) and made sure there are differences between the gradle files. Updated all packages and plugins.

    I just can't imagine the only difference between a working build is 2020 vs 2021
     
  14. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,663
    Did it help?
     
  15. trooper

    trooper

    Joined:
    Aug 21, 2009
    Posts:
    746
    Negative. No idea what to do next.
     
  16. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,663
    Without seeing the project it's really hard to say. I guess try doing Export Project instead and try to build it via Android Studio, maybe it will show you more information.
     
  17. TurgutHakki

    TurgutHakki

    Joined:
    Jun 15, 2017
    Posts:
    33
    What was the size of your APK before upgrade? Are you using asset bundles?