Search Unity

...\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:
    65
    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:
    39
    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:
    65
    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:
    80
    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)
     
    fahadzahid329 and mvaz_p like this.
  7. pavel_luden

    pavel_luden

    Joined:
    Apr 19, 2018
    Posts:
    6
    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. talibjan11

    talibjan11

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

    talibjan11

    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:
    189
    had the same issue, removed file from Assets/Plugins/Android/baseProjectTemplate.gradle and issue has gone.
     
  11. kdeger

    kdeger

    Joined:
    Mar 4, 2018
    Posts:
    22
    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".
     
    Bestgamingservices and virajs13 like this.
  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.
     
  13. moderebel

    moderebel

    Joined:
    Feb 20, 2018
    Posts:
    4
    Brilliant! A million thanks for this. Worked like a charm.
     
    thebestgames2021 likes this.
  14. umarkhaleeq

    umarkhaleeq

    Joined:
    Dec 16, 2018
    Posts:
    13
    I had the same error in working project on Unity version 2020.3.13f1.

    This work out for me:

    Open Assets/Plugins/Android/baseProjectTemplate.gradle

    Change classpath 'com.android.tools.build:gradle:3.4.0'

    to classpath 'com.android.tools.build:gradle:3.6.0'
     
    Crycoverr and amazighi1 like this.
  15. gamedevv2020

    gamedevv2020

    Joined:
    Oct 24, 2020
    Posts:
    1
    Worked for me, many thanks!
     
  16. DerekDittmerIT

    DerekDittmerIT

    Joined:
    Dec 14, 2017
    Posts:
    2
    Thanks pavel_luden!!!

    I tweaked it slightly so it works for development builds too:

    Code (CSharp):
    1. tasks.whenTaskAdded { task ->
    2.     if (task.name.startsWith("bundle")) {
    3.         def renameTaskName = "rename${task.name.capitalize()}Aab"
    4.         def flavor = task.name.substring("bundle".length()).uncapitalize()
    5.         tasks.create(renameTaskName, Copy) {
    6.             def path = "${buildDir}/outputs/bundle/${flavor}/"
    7.             from(path)
    8.             include "launcher-${flavor}.aab"
    9.             destinationDir file("${buildDir}/outputs/bundle/${flavor}/")
    10.             rename "launcher-${flavor}.aab", "launcher.aab"
    11.         }
    12.         task.finalizedBy(renameTaskName)
    13.     }
    14. }
     
  17. khanhabib

    khanhabib

    Joined:
    Oct 11, 2018
    Posts:
    29
  18. jorge_acm

    jorge_acm

    Joined:
    Dec 12, 2020
    Posts:
    6
    lol for me too, i thought was troll coment, but worked to mee haha thank =)
     
  19. unity_IRMgnPHB_Nj1_A

    unity_IRMgnPHB_Nj1_A

    Joined:
    Mar 9, 2019
    Posts:
    3
    the code will be like this after edit ??



    apply plugin: 'com.android.application'

    dependencies {
    implementation project(':unityLibrary')
    }

    android {
    compileSdkVersion **APIVERSION**
    buildToolsVersion '**BUILDTOOLS**'

    compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
    minSdkVersion **MINSDKVERSION**
    targetSdkVersion **TARGETSDKVERSION**
    applicationId '**APPLICATIONID**'
    ndk {
    abiFilters **ABIFILTERS**
    }
    versionCode **VERSIONCODE**
    versionName '**VERSIONNAME**'
    }

    aaptOptions {
    noCompress = ['.ress', '.resource', '.obb'] + unityStreamingAssets.tokenize(', ')
    ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
    }**SIGN**

    lintOptions {
    abortOnError false
    }

    buildTypes {
    debug {
    minifyEnabled **MINIFY_DEBUG**
    proguardFiles getDefaultProguardFile('proguard-android.txt')**SIGNCONFIG**
    jniDebuggable true
    }
    release {
    minifyEnabled **MINIFY_RELEASE**
    proguardFiles getDefaultProguardFile('proguard-android.txt')**SIGNCONFIG**
    }
    }**PACKAGING_OPTIONS****PLAY_ASSET_PACKS****SPLITS**
    **BUILT_APK_LOCATION**
    bundle {
    language {
    enableSplit = false
    }
    density {
    enableSplit = false
    }
    abi {
    enableSplit = true
    }
    }


    tasks.whenTaskAdded { task ->
    if (task.name.startsWith("bundle")) {
    def renameTaskName = "rename${task.name.capitalize()}Aab"
    def flavor = task.name.substring("bundle".length()).uncapitalize()
    tasks.create(renameTaskName, Copy) {
    def path = "${buildDir}/outputs/bundle/${flavor}/"
    from(path)
    include "launcher-release.aab"
    destinationDir file("${buildDir}/outputs/bundle/${flavor}/")
    rename "launcher-release.aab", "launcher.aab"
    }

    task.finalizedBy(renameTaskName)
    }
    }


    }**SPLITS_VERSION_CODE****LAUNCHER_SOURCE_BUILD_SETUP**
     
  20. unity_IRMgnPHB_Nj1_A

    unity_IRMgnPHB_Nj1_A

    Joined:
    Mar 9, 2019
    Posts:
    3
    where i must write this code ? can you explain more how to add it and where
     
  21. unity_IRMgnPHB_Nj1_A

    unity_IRMgnPHB_Nj1_A

    Joined:
    Mar 9, 2019
    Posts:
    3
    where i must add these lines ? can you explain more please ... i mean where i must add this code in any file ?
     
  22. amazighi1

    amazighi1

    Joined:
    Apr 16, 2018
    Posts:
    1
    thank you this solution worked for me when building .aab but for the .apk file I need to change the Gradle back to 3.4.3.
    using unity 2020.3.17f1
     
  23. Ajdar_div_salar

    Ajdar_div_salar

    Joined:
    May 30, 2020
    Posts:
    2
    Actually for me the code from this page worked:
    https://stackoverflow.com/questions...ut-launcher-build-outputs-bundle-release-laun

    im putting the whole file here for easier use:
    // GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN

    apply plugin: 'com.android.application'

    dependencies {
    implementation project(':unityLibrary')
    }

    android {
    compileSdkVersion **APIVERSION**
    buildToolsVersion '**BUILDTOOLS**'

    compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
    minSdkVersion **MINSDKVERSION**
    targetSdkVersion **TARGETSDKVERSION**
    applicationId '**APPLICATIONID**'
    ndk {
    abiFilters **ABIFILTERS**
    }
    versionCode **VERSIONCODE**
    versionName '**VERSIONNAME**'
    }

    aaptOptions {
    noCompress = ['.unity3d', '.ress', '.resource', '.obb'**STREAMING_ASSETS**]
    ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
    }**SIGN**

    lintOptions {
    abortOnError false
    }

    buildTypes {
    debug {
    minifyEnabled **MINIFY_DEBUG**
    proguardFiles getDefaultProguardFile('proguard-android.txt')**SIGNCONFIG**
    jniDebuggable true
    }
    release {
    minifyEnabled **MINIFY_RELEASE**
    proguardFiles getDefaultProguardFile('proguard-android.txt')**SIGNCONFIG**
    }
    }**PACKAGING_OPTIONS****SPLITS**
    **BUILT_APK_LOCATION**
    bundle {
    language {
    enableSplit = false
    }
    density {
    enableSplit = false
    }
    abi {
    enableSplit = true
    }
    }

    tasks.whenTaskAdded { task ->
    if (task.name.startsWith("bundle")) {
    def renameTaskName = "rename${task.name.capitalize()}Aab"
    def flavor = task.name.substring("bundle".length()).uncapitalize()
    tasks.create(renameTaskName, Copy) {
    def path = "${buildDir}/outputs/bundle/${flavor}/"
    from(path)
    include "launcher.aab"
    destinationDir file("${buildDir}/outputs/bundle/${flavor}/")
    rename "launcher.aab", "launcher-release.aab"
    }
    task.finalizedBy(renameTaskName)
    }
    }
    }**SPLITS_VERSION_CODE****LAUNCHER_SOURCE_BUILD_SETUP**
     
  24. doubletapsoft

    doubletapsoft

    Joined:
    Sep 23, 2013
    Posts:
    32
    I am having similar problem, getting this error.

    Code (CSharp):
    1. temp\gradleout\launcher\build\outputs\bundle\release\launcher-release.aab does not exist
    NOTE: It says missing launcher-release.aab not launcher.aab like in the first message of this post.

    Using Unity 2020.3.8f1 (LTS).

    How do we fix this?
     
  25. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,920
    You probably have a gradle template in your project, which is not compatible, you might need to recreate it.
     
  26. doubletapsoft

    doubletapsoft

    Joined:
    Sep 23, 2013
    Posts:
    32
    Okay I replaced the gradle templates in my Unity project with the ones from below and it seemed to have fixed the issue.

    /Applications/2020.3.8f1/PlaybackEngines/AndroidPlayer/Tools
     
    Last edited: Oct 26, 2022
    Tomas1856 likes this.