FileNotFoundException: Temp\...\launcher.aab does not exist

项目场景:

Unity导出AAB文件错误。

问题描述:

错误信息如下:

FileNotFoundException: Temp\gradleOut\launcher\build\outputs\bundle\release\launcher.aab does not exist
System.IO.File.Move (System.String sourceFileName, System.String destFileName) (at <9577ac7a62ef43179789031239ba8798>:0)
UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <a5ce51c3ac7942f89b38f5afb48efa1b>:0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <a5ce51c3ac7942f89b38f5afb48efa1b>: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 <a5ce51c3ac7942f89b38f5afb48efa1b>:0)
UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <a5ce51c3ac7942f89b38f5afb48efa1b>: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 <599cc8297d774c7eab3d57de775dc8cb>:0)
UnityEditor.BuildPipeline:BuildPlayer(BuildPlayerOptions)
Google.Android.AppBundle.Editor.Internal.BuildTools.AndroidBuilder:Build(BuildPlayerOptions) (at Assets/ThirdParty/GooglePlayPlugins/com.google.android.appbundle/Editor/Scripts/Internal/BuildTools/AndroidBuilder.cs:108)
Google.Android.AppBundle.Editor.Internal.BuildTools.AppBundleBuilder:BuildAndroidPlayer(BuildPlayerOptions) (at Assets/ThirdParty/GooglePlayPlugins/com.google.android.appbundle/Editor/Scripts/Internal/BuildTools/AppBundleBuilder.cs:172)
Google.Android.AppBundle.Editor.Internal.AppBundlePublisher:Build(AppBundleBuilder, BuildPlayerOptions, AssetPackConfig, AppBundleBuildSettings) (at Assets/ThirdParty/GooglePlayPlugins/com.google.android.appbundle/Editor/Scripts/Internal/AppBundlePublisher.cs:153)
Google.Android.AppBundle.Editor.Internal.AppBundlePublisher:Build() (at Assets/ThirdParty/GooglePlayPlugins/com.google.android.appbundle/Editor/Scripts/Internal/AppBundlePublisher.cs:97)
Google.Android.AppBundle.Editor.Internal.AppBundleEditorMenu:BuildAndroidAppBundle() (at Assets/ThirdParty/GooglePlayPlugins/com.google.android.appbundle/Editor/Scripts/Internal/AppBundleEditorMenu.cs:66)

原因分析:

gradle版本过高,导致与unity内部逻辑不兼容。

解决方案:

由于降低gradle版本可能引起一些列其他问题,所以不建议降低gradle版本;

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

将下面这段代码贴到自定义 launcherTemplate.gradle 的底部

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

this code should rename your launcher-release.aab to launcher.aab
praise David Medenjak from

  • 3
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值