问题描述Unity 2020.1.14f1
baseProjectTemplate:classpath ‘com.android.tools.build:gradle:3.6.0’
Gradle版本:5.6.4
打包Apk是没有问题的,但是现在需要打包成aab,上传Google Play后台,报错信息如下
FileNotFoundException: Temp\gradleOut\launcher\build\outputs\bundle\release\launcher-release.aab does not exist
System.IO.File.Move (System.String sourceFileName, System.String destFileName) (at <695d1cc93cca45069c528c15c9fdd749>:0)
UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <2c6e9a95f1dd4e06ad71afcd2684dcb7>:0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <2c6e9a95f1dd4e06ad71afcd2684dcb7>: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,
二、原因
网上搜索的原因如下
gradle版本过高,导致与unity内部逻辑不兼容。
解决方法: launcherTemplate的defaultConfig里添加了下列的代码
defaultConfig {
***
//添加以下内容
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)
}
}
}
上述方法并不能解决我的问题,目前来看原因还不是很清楚,如果你知道的话,可以私信博主,感谢
三、解决方法
PlayerSettings->Publishing Settings,勾选Assets->Plugins->Android->baseProjectTemplate.gradle,双击打开,修改版本为“4.0.1”
对应的Unity的Gradle版本也要升级到6.1.1,插件版本与Gradle版本对应关系如下
插件版本与Gradle版本关系
升级版本Gradle
Unity的Gradle路径:D:\Unity3D\2020.1.14f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle
删除gradle文件夹下的lib文件夹
下载Gradle
Gradle下载地址
下载完成后,解压压缩包,复制lib文件夹到D:\Unity3D\2020.1.14f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle
重新打开Unity ,可以正常打包aab.。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)