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:
    1
    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:
    4
    Same thing happening here, there is no aab file in Temp/gradleOut/build/outputs/bundle/release/.
     
  4. spleendays

    spleendays

    Joined:
    Jul 21, 2013
    Posts:
    5
    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
    mvaz_p likes 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:
    5
    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:
    5
    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:
    5
    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:
    5
    You are welcome.