FileNotFoundException while building apk

I have an error while building android apk.

FileNotFoundException: Temp\gradleOut\build\outputs\apk\release\gradleOut-release.apk 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.BuildReporting.BuildReport report)
UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (BuildPostProcessArgs args)
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.BuildReporting.BuildReport report) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/PostprocessBuildPlayer.cs:272)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

It shows that ā€œTemp\gradleOut\build\outputs\apk\release\gradleOut-release.apkā€ does not exist, but I can find the file in ā€œTemp\gradleOut\build\outputs\apk\gradleOut-release.apkā€.

How can I correct this?

EDIT: I’m Unity 2017.4.17f, too.

I have same issue.

EDIT: Unity 2017.4.17f

I may solved.
change gradle version in Plugin/Android/mainTemplate.gradle ā€˜3.2.0’

repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
}
}```
2 Likes

Unity2017.4.18 have same issue.
I solved it. Thank you.

its help me too! My problem was:

FileNotFoundException: Temp/gradleOut/build/outputs/bundle/release/gradleOut.aab does not exist

I have same issue.

Unity2017.4.26f1

FileNotFoundException: Temp\gradleOut\build\outputs\apk\release\gradleOut-release.apk 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.BuildReporting.BuildReport report)
UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (BuildPostProcessArgs args)
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.BuildReporting.BuildReport report) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/PostprocessBuildPlayer.cs:272)
UnityEngine.GUIUtility:processEvent(Int32, IntPtr)

But:

  1. It shows that ā€œTemp\gradleOut\build\outputs\apk\release\gradleOut-release.apkā€ does not exist, and I actually DO NOT find the file

  2. the gradle version in Plugin/Android/mainTemplate.gradle has been ā€˜3.2.0’, NEED NOT TO CHANGE

and the issue is still here.

so, what should I do?

thx for help.

1 Like

The same problem:
FileNotFoundException: Temp\gradleOut\build\outputs\apk\release\gradleOut-armeabi-v7a-release.apk does not exist
Unity 2019.1.3f1

mainTemplate.gradle:

// GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN
buildscript {
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.0'
    }
}

allprojects {
   repositories {
    google()
    jcenter()
      flatDir {
        dirs 'libs'
      }
   }
}

apply plugin: 'com.android.application'

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
**DEPS**}

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

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

    lintOptions {
        checkReleaseBuilds false    //dirty hack
        abortOnError false
    }

    aaptOptions {
        noCompress '.unity3d', '.ress', '.resource', '.obb'**STREAMING_ASSETS**
    }

**SIGN**
    buildTypes {
          debug {
             minifyEnabled **MINIFY_DEBUG**
             useProguard **PROGUARD_DEBUG**
             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'**USER_PROGUARD**
              jniDebuggable true
          }
          release {
             minifyEnabled **MINIFY_RELEASE**
             useProguard **PROGUARD_RELEASE**
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'**USER_PROGUARD**
              **SIGNCONFIG**
          }
    }
**PACKAGING_OPTIONS**
}


**SOURCE_BUILD_SETUP**

Greate, it’s work for me too.

is this issue solved?

it do not use:(

I solved it by create a apk named this in where it wrong…

But it can’t run…

Same issue here.

FileNotFoundException: Temp\gradleOut\build\outputs\bundle\release\gradleOut.aab does not exist
System.IO.File.Move (System.String sourceFileName, System.String destFileName) (at :0)
UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at :0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at :0)
UnityEditor.Android.PostProcessAndroidPlayer.PostProcess (UnityEditor.BuildTarget target, System.String stagingAreaData, System.String stagingArea, System.String playerPackage, System.String installPath, System.String companyName, System.String productName, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at :0)
UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at :0)
UnityEditor.PostprocessBuildPlayer.Postprocess (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget target, System.String installPath, System.String companyName, System.String productName, System.Int32 width, System.Int32 height, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/PostprocessBuildPlayer.cs:288)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr) (at C:/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:179)

I have no idea why Unity people didn’t yet respond on this.

I can see the .aab file on that location but its not names as it is looking for while building instead of gradleOut.aab the file name there is gradleOut-release.aab.

I have renamed it and lets see if it works.

Renaming didn’t work :frowning: as it cleans and creates a new file named gradleOut-release.aab ? Does anyone have any solution?

I have the same issue: Unity Cloud Build, Latest 2018.4

Hey everybody, following this post ...\bundle\release\launcher.aab does not exist 2019.4.16f1 - Unity Engine - Unity Discussions and some other forum posts I have finally able to build aab.

    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 "gradleOut-release.aab"
                destinationDir file("${buildDir}/outputs/bundle/${flavor}/")
                rename "gradleOut-release.aab", "gradleOut.aab"
            }
   
            task.finalizedBy(renameTaskName)
        }
    }

Add this code to mainTemplate, inside the bottom of defaultConfig. This works for Unity versions without the option to create custom launcherTemplate.gradle, if you have the option to create launcherTemplate.gradle, you can paste this code to the bottom of it.

Hope this helps.

1 Like

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.

Im having the same issue. Unity version : 2019.4.19f

Nevermind i solved the problem by adding this code

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)
    }
}

to defaultConfig section of launcherTemplate.gradle

now its look like this

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

        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)
            }
        }
}