Search Unity

Android App Bundle (.aab) FileNotFoundException when building

Discussion in 'Editor & General Support' started by Raisanen, Jan 9, 2019.

  1. Raisanen

    Raisanen

    Joined:
    Jan 18, 2017
    Posts:
    3
    Hi,
    I just updated the Unity to version 2018.3.0f2 and tried building the .aab file from my project. Unity said the build was successful, but it also threw this error and there is no build.

    Any ideas how to solve this or what could be the issue?

    FileNotFoundException: Temp/gradleOut/build/outputs/bundle/release/gradleOut.aab does not exist
    System.IO.File.Move (System.String sourceFileName, System.String destFileName) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.IO/File.cs:318)
    UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context)
    UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context)
    UnityEditor.Android.PostProcessAndroidPlayer.PostProcess (BuildTarget target, System.String stagingAreaData, System.String stagingArea, System.String playerPackage, System.String installPath, System.String companyName, System.String productName, BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report)
    UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties)
    UnityEditor.PostprocessBuildPlayer.Postprocess (BuildTargetGroup targetGroup, BuildTarget target, System.String installPath, System.String companyName, System.String productName, Int32 width, Int32 height, BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/PostprocessBuildPlayer.cs:286)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)
     
  2. boriss_unity

    boriss_unity

    Unity Technologies

    Joined:
    Oct 11, 2017
    Posts:
    14
    Hi,
    Do you see any aab file in Temp/gradleOut/build/outputs/bundle/release/ directory?
     
  3. mvaz_p

    mvaz_p

    Joined:
    Aug 22, 2018
    Posts:
    80
    Same thing happening here, there is no aab file in Temp/gradleOut/build/outputs/bundle/release/.
     
  4. spleendays

    spleendays

    Joined:
    Jul 21, 2013
    Posts:
    8
    Hi,

    Are you using a custom gradle file ? (Player Settings > Checkbox named "Custom Gradle Template")

    I had this exact same error, that i eventually managed to fix by updating the content of my mainTemplate.gradle file (which is located in Assets/Plugins/Android ), after comparing it with the default gradle template of Unity 2018.3.1f1 :

    [path to Unity]/PlaybackEngines/AndroidPlayer/Tools/GradleTemplates/mainTemplate.gradle


    I was so excited by the idea of being able to build an aab file (android aab files allow users to get smaller, more optimized downloads) that i completely forgot to double check the content of the new gradle template :)

    The following thread appeared to be a livesaver to me :

    https://forum.unity.com/threads/gradle-error-during-android-building.569113/

    (check ScottyB's post)
     
    Last edited: Jan 13, 2019
    williambelll and mvaz_p like this.
  5. GodManOmar777

    GodManOmar777

    Joined:
    May 27, 2017
    Posts:
    6
    so how do u fixed this error i got this one
    FileNotFoundException: Temp\gradleOut\build\outputs\bundle\release\gradleOut.aab does not exist
     
  6. spleendays

    spleendays

    Joined:
    Jul 21, 2013
    Posts:
    8
    Hi @GodManOmar777, what is your version of unity ?

    You need to update the content of your mainTemplate.gradle file (which is located in Assets/Plugins/Android ), by comparing it with the default gradle template of your Unity :

    [path to Unity]/PlaybackEngines/AndroidPlayer/Tools/GradleTemplates/mainTemplate.gradle
     
  7. GodManOmar777

    GodManOmar777

    Joined:
    May 27, 2017
    Posts:
    6
  8. GodManOmar777

    GodManOmar777

    Joined:
    May 27, 2017
    Posts:
    6
     
  9. spleendays

    spleendays

    Joined:
    Jul 21, 2013
    Posts:
    8
    Ok, can you post the contents of your mainTemplate.gradle file ? (please use the "Insert code" button)
     
  10. GodManOmar777

    GodManOmar777

    Joined:
    May 27, 2017
    Posts:
    6
    Code (CSharp):
    1. buildscript {
    2.     repositories {
    3.         jcenter()
    4.         google()
    5.     }
    6.  
    7.     dependencies {
    8.         classpath 'com.android.tools.build:gradle:3.2.0-alpha15'
    9.  
    10.  
    11. **BUILD_SCRIPT_DEPS**}
    12. }
    13.  
    14. allprojects {
    15.     repositories {
    16.         jcenter()
    17.         google()
    18.         flatDir {
    19.             dirs 'libs'
    20.         }
    21.     }
    22. }
    23.  
    24. apply plugin: 'com.android.application'
    25. **APPLY_PLUGINS**
    26.  
    27. dependencies {
    28.     implementation fileTree(dir: 'libs', include: ['*.jar'])
    29. **DEPS**}
    30.  
    31. android {
    32.     compileSdkVersion **APIVERSION**
    33.     buildToolsVersion '**BUILDTOOLS**'
    34.  
    35.     compileOptions {
    36.         sourceCompatibility JavaVersion.VERSION_1_8
    37.         targetCompatibility JavaVersion.VERSION_1_8
    38.     }
    39.  
    40.     defaultConfig {
    41.         minSdkVersion **MINSDKVERSION**
    42.         targetSdkVersion **TARGETSDKVERSION**
    43.         applicationId '**APPLICATIONID**'
    44.         ndk {
    45.             abiFilters **ABIFILTERS**
    46.         }
    47.         versionCode **VERSIONCODE**
    48.         versionName '**VERSIONNAME**'
    49.     }
    50.  
    51.     lintOptions {
    52.         abortOnError false
    53.     }
    54.  
    55.     aaptOptions {
    56.         noCompress = ['.unity3d', '.ress', '.resource', '.obb'**STREAMING_ASSETS**]
    57.     }**SIGN**
    58.  
    59.     buildTypes {
    60.         debug {
    61.             minifyEnabled **MINIFY_DEBUG**
    62.             useProguard **PROGUARD_DEBUG**
    63.             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'**USER_PROGUARD**
    64.             jniDebuggable true
    65.         }
    66.         release {
    67.             minifyEnabled **MINIFY_RELEASE**
    68.             useProguard **PROGUARD_RELEASE**
    69.             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'**USER_PROGUARD****SIGNCONFIG**
    70.         }
    71.     }**PACKAGING_OPTIONS****SPLITS**
    72. **BUILT_APK_LOCATION**
    73.     bundle {
    74.         language {
    75.             enableSplit = false
    76.         }
    77.         density {
    78.             enableSplit = false
    79.         }
    80.         abi {
    81.             enableSplit = true
    82.         }
    83.     }
    84. }**SPLITS_VERSION_CODE****REPOSITORIES****SOURCE_BUILD_SETUP**
    [path to Unity]/PlaybackEngines/AndroidPlayer/Tools/GradleTemplates/mainTemplate.gradle
     
    Last edited: May 19, 2019
  11. GodManOmar777

    GodManOmar777

    Joined:
    May 27, 2017
    Posts:
    6
    thanks that did work your a lifesaver
     
  12. spleendays

    spleendays

    Joined:
    Jul 21, 2013
    Posts:
    8
    You're welcome : )

    I would recommend to put google() before jcenter(), and to use 'com.android.tools.build:gradle:3.2.0'.

    Best Regards,

    Franck.

    Code (CSharp):
    1.  
    2.  
    3. buildscript {
    4.     repositories {
    5.         google()
    6.         jcenter()
    7.     }
    8.  
    9.     dependencies {
    10.         classpath 'com.android.tools.build:gradle:3.2.0'
    11. **BUILD_SCRIPT_DEPS**
    12.     }
    13. }
    14.  
    15. allprojects {
    16.     repositories {
    17.         google()
    18.         jcenter()
    19.         flatDir {
    20.             dirs 'libs'
    21.         }
    22.     }
    23. }
    24.  
     
  13. truonghkx

    truonghkx

    Joined:
    Jun 7, 2017
    Posts:
    1
    Thanks spleendays, you save my life.
     
  14. spleendays

    spleendays

    Joined:
    Jul 21, 2013
    Posts:
    8
    You are welcome.
     
  15. williambelll

    williambelll

    Joined:
    Jul 4, 2017
    Posts:
    1
    saved my day! thanks spleendays
     
  16. spleendays

    spleendays

    Joined:
    Jul 21, 2013
    Posts:
    8
    No problem williambelll
     
  17. pavel_luden

    pavel_luden

    Joined:
    Apr 19, 2018
    Posts:
    6
    ltomov likes this.
  18. utsavappindia

    utsavappindia

    Joined:
    Mar 26, 2019
    Posts:
    7
    Hi, I am working project on Unity version 2020.2.6f1. But when I build AAB for my project, the build gets failed & gets an Error Log.

    Here is the Error log :
    FileNotFoundException: Temp/gradleOut/launcher/build/outputs/bundle/release/launcher-release.aab does not exist.

    Please Help to Resolve this problem.
     
  19. spleendays

    spleendays

    Joined:
    Jul 21, 2013
    Posts:
    8
    Hello,

    Are you using a custom gradle file ? (File > Build Settings > Player Settings > Checkbox named "Custom Gradle Template")

    If it's the case, here is a quickfix :

    Locate the custom gradle template file (the path is shown below the checkbox), make a backup copy of this file for further analysis / adjustments, and delete it. It will be automatically re-generated by Unity.

    Custom gradle template file path :

    [PATH TO YOUR UNITY PROJECT]/Assets/Plugins/Android/mainTemplate.gradle


    Then, if needed, perform a "Force Resolve" :

    Assets > External Dependency Manager > Android Resolver > Force Resolve

    This will update the mainTemplate.gradle file contents adequately.


    You may also need to make manual adjustments to this file depending on the contents of your backup copy of this file.


    A while ago I had this exact same error, that i eventually managed to fix by manually updating the contents of my custom mainTemplate.gradle file, after comparing it with the default gradle template of Unity, located at :

    [PATH TO YOUR INSTALL OF UNITY]/PlaybackEngines/AndroidPlayer/Tools/GradleTemplates/mainTemplate.gradle

    Best Regards,

    Franck
     
    Last edited: May 15, 2021
  20. andrew_pearce_

    andrew_pearce_

    Joined:
    Nov 5, 2018
    Posts:
    169
    None of the above worked for me but I found solution here which suggested to use this code. However, I had to change "launcher-release.aab" with "gradleOut-release.aab" and "launcher.aab" with "gradleOut.aab".
     
    PFUnity3 and khanhabib like this.
  21. spleendays

    spleendays

    Joined:
    Jul 21, 2013
    Posts:
    8
    Thanks for the feedback.
     
  22. AdnanSiddique

    AdnanSiddique

    Joined:
    Dec 14, 2015
    Posts:
    1
    I am using unity 2020.3.14f, I resolved this issue by just removing baseProjectTemplate from my project. Hope it help others as well.
     
    ukgrafix and khanhabib like this.
  23. khanhabib

    khanhabib

    Joined:
    Oct 11, 2018
    Posts:
    29
  24. Ga2Z

    Ga2Z

    Joined:
    Feb 16, 2012
    Posts:
    68
  25. rwvanta

    rwvanta

    Joined:
    Feb 28, 2020
    Posts:
    1
    ArtemVy and khanhabib like this.
  26. khanhabib

    khanhabib

    Joined:
    Oct 11, 2018
    Posts:
    29
    i got the same issue and i solved it. the above are only gradle files to help others, everyone can understand it.
     
  27. ukgrafix

    ukgrafix

    Joined:
    Apr 26, 2022
    Posts:
    1
    Thanks Adnan, it worked for me