Search Unity

  1. All Pro and Enterprise subscribers: find helpful & inspiring creative, tech, and business know-how in the new Unity Success Hub. Sign in to stay up to date.
    Dismiss Notice
  2. Dismiss Notice

...\bundle\release\launcher.aab does not exist 2019.4.16f1

Discussion in 'Android' started by afftar, Dec 19, 2020.

  1. afftar

    afftar

    Joined:
    Apr 18, 2014
    Posts:
    57
    FileNotFoundException: Temp\gradleOut\launcher\build\outputs\bundle\release\launcher.aab does not exist


    When trying to update Gradle to version 3.6.0+, I came across the fact that the file that comes out has a different name than the unit expects.

    In the folder I see the file: launcher-release.aab

    How can I remove "-release" from the name? Or give Unity a new filename?

    My launcherTemplate.gradle:
    Code (JavaScript):
    1. buildscript {
    2.     repositories {
    3.         google()
    4.         jcenter()
    5.     }
    6.     dependencies {
    7.         // Must be Android Gradle Plugin 3.6.0 or later. For a list of
    8.         // compatible Gradle versions refer to:
    9.         // https://developer.android.com/studio/releases/gradle-plugin
    10.         classpath 'com.android.tools.build:gradle:3.6.0'
    11.     }
    12. }
    13.  
    14. allprojects {
    15.    repositories {
    16.       google()
    17.       jcenter()
    18.       flatDir {
    19.         dirs 'libs'
    20.       }
    21.    }
    22. }
    23.  
    24.  
    25.  
    26. apply plugin: 'com.android.application'
    27.  
    28. dependencies {
    29.     implementation project(':unityLibrary')
    30.     }
    31.  
    32. android {
    33.     compileSdkVersion **APIVERSION**
    34.     buildToolsVersion '**BUILDTOOLS**'
    35.  
    36.     compileOptions {
    37.         sourceCompatibility JavaVersion.VERSION_1_8
    38.         targetCompatibility JavaVersion.VERSION_1_8
    39.     }
    40.  
    41.     defaultConfig {
    42.         minSdkVersion **MINSDKVERSION**
    43.         targetSdkVersion **TARGETSDKVERSION**
    44.         applicationId '**APPLICATIONID**'
    45.         ndk {
    46.             abiFilters **ABIFILTERS**
    47.         }
    48.         versionCode **VERSIONCODE**
    49.         versionName '**VERSIONNAME**'
    50.     }
    51.  
    52.     aaptOptions {
    53.         noCompress = ['.unity3d', '.ress', '.resource', '.obb'**STREAMING_ASSETS**]
    54.         ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
    55.     }**SIGN**
    56.  
    57.     lintOptions {
    58.         abortOnError false
    59.     }
    60.  
    61.     buildTypes {
    62.         debug {
    63.             minifyEnabled **MINIFY_DEBUG**
    64.             useProguard **PROGUARD_DEBUG**
    65.             proguardFiles getDefaultProguardFile('proguard-android.txt')**SIGNCONFIG**
    66.             jniDebuggable true
    67.         }
    68.         release {
    69.             minifyEnabled **MINIFY_RELEASE**
    70.             useProguard **PROGUARD_RELEASE**
    71.             proguardFiles getDefaultProguardFile('proguard-android.txt')**SIGNCONFIG**
    72.         }
    73.     }**PACKAGING_OPTIONS****SPLITS**
    74. **BUILT_APK_LOCATION**
    75.     bundle {
    76.         language {
    77.             enableSplit = false
    78.         }
    79.         density {
    80.             enableSplit = false
    81.         }
    82.         abi {
    83.             enableSplit = true
    84.         }
    85.     }
    86. }**SPLITS_VERSION_CODE****LAUNCHER_SOURCE_BUILD_SETUP**
    87.  
     

    Attached Files:

  2. Jumeuan

    Jumeuan

    Joined:
    Mar 14, 2017
    Posts:
    30
    Same issue when build AAB android with options:
    Code (CSharp):
    1. - Enable mainGradle
    2. - Enable baseGradle
    3. - Enable launcherGradle
    4. - Use Gradle 3.6.0 / 5.6.4
    It is building success complete, but when Unity try to copy .aar file, path is wrong.
    It must be:
    Code (CSharp):
    1. Temp\gradleOut\launcher\build\outputs\bundle\release\launcher-release.aab
     
  3. afftar

    afftar

    Joined:
    Apr 18, 2014
    Posts:
    57
    Best unity support, however, as usual
     
    ArthurAulicino likes this.
  4. rlehmann_unity

    rlehmann_unity

    Joined:
    Jul 5, 2019
    Posts:
    1
    Bump! :)
    Having the same issue, we needed to update Gradle due to some plugins (Facebook....)
    but now the build fails because of the different naming...
     
  5. mvaz_p

    mvaz_p

    Joined:
    Aug 22, 2018
    Posts:
    50
    Managed to find a workaround:

    Code (CSharp):
    1. #if UNITY_ANDROID
    2. using UnityEditor.Build;
    3. using UnityEditor.Build.Reporting;
    4.  
    5. public class TempGradleAndroidPreProcessBuild : IPreprocessBuildWithReport
    6. {
    7.     public int callbackOrder => 0;
    8.  
    9.     public void OnPreprocessBuild (BuildReport report)
    10.     {
    11.         TempGradleFileWatcher.Start();
    12.     }
    13. }
    14. #endif
    15.  

    Code (CSharp):
    1. #if UNITY_ANDROID
    2. using UnityEditor;
    3. using UnityEditor.Callbacks;
    4.  
    5. public class TempGradleAndroidPostProcessBuild
    6. {
    7.     [PostProcessBuild(0)]
    8.     public static void ChangeGradleLauncherName (BuildTarget buildTarget, string pathToBuiltProject)
    9.     {
    10.         TempGradleFileWatcher.Stop();
    11.     }
    12. }
    13. #endif
    14.  

    Code (CSharp):
    1. using System.IO;
    2. using UnityEngine;
    3.  
    4. public static class TempGradleFileWatcher
    5. {
    6.     const string OLD_NAME = "launcher-release.aab";
    7.     const string NEW_NAME = "launcher.aab";
    8.  
    9.     static string fileName;
    10.     static string newFileName;
    11.     static FileSystemWatcher watcher;
    12.  
    13.     public static void Start ()
    14.     {
    15.         string tempPath = Path.Combine(
    16.             Application.dataPath,
    17.             "..",
    18.             "Temp",
    19.             "gradleOut",
    20.             "launcher",
    21.             "build",
    22.             "outputs",
    23.             "bundle",
    24.             "release"
    25.         );
    26.         fileName = Path.Combine(tempPath, OLD_NAME);
    27.         newFileName = Path.Combine(tempPath, NEW_NAME);
    28.  
    29.         watcher = new FileSystemWatcher
    30.         {
    31.             Path = tempPath,
    32.             NotifyFilter = NotifyFilters.LastAccess
    33.             | NotifyFilters.LastWrite
    34.             | NotifyFilters.FileName
    35.             | NotifyFilters.DirectoryName,
    36.             Filter = OLD_NAME,
    37.             EnableRaisingEvents = true
    38.         };
    39.         watcher.Created += OnCreated;
    40.     }
    41.  
    42.     public static void Stop ()
    43.     {
    44.         if (watcher != null)
    45.             watcher.Dispose();
    46.     }
    47.  
    48.     static void OnCreated (object sender, FileSystemEventArgs e) =>
    49.         File.Move(fileName, newFileName);
    50. }
    51.  
    It should start watching the Temp/gradleOut... folder when the build starts and change the file name to the expected one. Stops watching when the build ends.

    This issue should be analyzed by the Unity team, because there doesn't seem to be a proper way to modify this file through the build pipeline (please, correct me if I'm wrong). Tried using IPostGenerateGradleAndroidProject, but the changes were overridden.
     
    Jumeuan and ArthurAulicino like this.
  6. SanCaGon

    SanCaGon

    Joined:
    Jul 21, 2019
    Posts:
    1
    Thanks for the code mvaz_p, i tried that fix but it didn't work for me. However it gave me the idea to use a python script to do the same thing, and it worked!

    Here's the snippet for anyone interested, just put the file inside the project folder and execute it before building:

    Code (Python):
    1. import os
    2. import time
    3.  
    4. path = "Temp/gradleOut/launcher/build/outputs/bundle/release/launcher-release.aab"
    5. pathNew = "Temp/gradleOut/launcher/build/outputs/bundle/release/launcher.aab"
    6.  
    7. print("Searching for file...")
    8. while True:
    9.    if os.path.isfile(path):
    10.        try:
    11.            os.rename(path, pathNew)
    12.            print("FILE RENAMED!")
    13.            break
    14.        except Exception as e:
    15.            pass
    16.        else:
    17.            pass
    18.        finally:
    19.            pass
    20.  
    21.    time.sleep(0.01)
     
    mvaz_p likes this.
  7. pavel_luden

    pavel_luden

    Joined:
    Apr 19, 2018
    Posts:
    3
    Sup, guys.

    Totally agree, unity should pay attention to this issue.
    It is so easy to reproduce:
    1. unity 2019.4.17 + external gradle-6.7.1
    2. add classpath 'com.android.tools.build:gradle:3.6.0' to dependencies
    3. try to build aab
    Result: FileNotFoundException launcher.aab does not exist

    Workaround: drop this to the bottom of your custom launcherTemplate.gradle
    Code (CSharp):
    1.  
    2. tasks.whenTaskAdded { task ->
    3.     if (task.name.startsWith("bundle")) {
    4.         def renameTaskName = "rename${task.name.capitalize()}Aab"
    5.         def flavor = task.name.substring("bundle".length()).uncapitalize()
    6.         tasks.create(renameTaskName, Copy) {
    7.             def path = "${buildDir}/outputs/bundle/${flavor}/"
    8.             from(path)
    9.             include "launcher-release.aab"
    10.             destinationDir file("${buildDir}/outputs/bundle/${flavor}/")
    11.             rename "launcher-release.aab", "launcher.aab"
    12.         }
    13.  
    14.         task.finalizedBy(renameTaskName)
    15.     }
    16. }
    17.  
    this code should rename your launcher-release.aab to launcher.aab
    praise David Medenjak from https://stackoverflow.com/questions...enerated-filename-for-app-bundles-with-gradle
     
  8. BestGameplay

    BestGameplay

    Joined:
    Feb 23, 2018
    Posts:
    2
  9. BestGameplay

    BestGameplay

    Joined:
    Feb 23, 2018
    Posts:
    2
    1. classpath 'com.android.tools.build:gradle:3.4.3' us this
     
  10. kmedved

    kmedved

    Joined:
    Aug 18, 2016
    Posts:
    122
    had the same issue, removed file from Assets/Plugins/Android/baseProjectTemplate.gradle and issue has gone.
     
    Antony-Blackett likes this.
  11. kdeger

    kdeger

    Joined:
    Mar 4, 2018
    Posts:
    20
    For anyone using older versions of Unity(which doesn't have an option to create Custom launcherTemplate), just paste the code to mainTemplate, inside the bottom of defaultConfig. It also works for FileNotFoundException for gradleOut-release.aab too, just change every "launcher" to "gradleOut".
     
  12. 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.
     
    LidiaBestGameDesigner likes this.
  13. moderebel

    moderebel

    Joined:
    Feb 20, 2018
    Posts:
    2
    Brilliant! A million thanks for this. Worked like a charm.
     
unityunity