Add .aab bundling for Android.
This commit is contained in:
@@ -364,27 +364,54 @@ bool AndroidPlatformTools::OnPostProcess(CookingData& data)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
const bool distributionPackage = buildSettings->ForDistribution || data.Configuration == BuildConfiguration::Release;
|
const bool distributionPackage = buildSettings->ForDistribution || data.Configuration == BuildConfiguration::Release;
|
||||||
|
if (data.CustomDefines.Contains(String(TEXT("BuildAAB"))))
|
||||||
{
|
{
|
||||||
CreateProcessSettings procSettings;
|
// .aab
|
||||||
procSettings.FileName = String::Format(TEXT("\"{0}\" {1}"), data.OriginalOutputPath / gradlew, distributionPackage ? TEXT("assemble") : TEXT("assembleDebug"));
|
|
||||||
procSettings.WorkingDirectory = data.OriginalOutputPath;
|
|
||||||
const int32 result = Platform::CreateProcess(procSettings);
|
|
||||||
if (result != 0)
|
|
||||||
{
|
{
|
||||||
data.Error(String::Format(TEXT("Failed to build Gradle project into package (result code: {0}). See log for more info."), result));
|
CreateProcessSettings procSettings;
|
||||||
|
procSettings.FileName = String::Format(TEXT("\"{0}\" {1}"), data.OriginalOutputPath / gradlew, distributionPackage ? TEXT(":app:bundle") : TEXT(":app:bundleDebug"));
|
||||||
|
procSettings.WorkingDirectory = data.OriginalOutputPath;
|
||||||
|
const int32 result = Platform::CreateProcess(procSettings);
|
||||||
|
if (result != 0)
|
||||||
|
{
|
||||||
|
data.Error(String::Format(TEXT("Failed to build Gradle project into package (result code: {0}). See log for more info."), result));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Copy result package
|
||||||
|
const String aab = data.OriginalOutputPath / (distributionPackage ? TEXT("app/build/outputs/apk/release/app-release.aab") : TEXT("app/build/outputs/bundle/debug/app-debug.aab"));
|
||||||
|
const String outputAab = data.OriginalOutputPath / EditorUtilities::GetOutputName() + TEXT(".aab");
|
||||||
|
if (FileSystem::CopyFile(outputAab, aab))
|
||||||
|
{
|
||||||
|
LOG(Error, "Failed to copy package from {0} to {1}", aab, outputAab);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
LOG(Info, "Output Android application package: {0} (size: {1} MB)", outputAab, FileSystem::GetFileSize(outputAab) / 1024 / 1024);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
// Copy result package
|
|
||||||
const String apk = data.OriginalOutputPath / (distributionPackage ? TEXT("app/build/outputs/apk/release/app-release-unsigned.apk") : TEXT("app/build/outputs/apk/debug/app-debug.apk"));
|
|
||||||
const String outputApk = data.OriginalOutputPath / EditorUtilities::GetOutputName() + TEXT(".apk");
|
|
||||||
if (FileSystem::CopyFile(outputApk, apk))
|
|
||||||
{
|
{
|
||||||
LOG(Error, "Failed to copy package from {0} to {1}", apk, outputApk);
|
// .apk
|
||||||
return true;
|
{
|
||||||
|
CreateProcessSettings procSettings;
|
||||||
|
procSettings.FileName = String::Format(TEXT("\"{0}\" {1}"), data.OriginalOutputPath / gradlew, distributionPackage ? TEXT("assemble") : TEXT("assembleDebug"));
|
||||||
|
procSettings.WorkingDirectory = data.OriginalOutputPath;
|
||||||
|
const int32 result = Platform::CreateProcess(procSettings);
|
||||||
|
if (result != 0)
|
||||||
|
{
|
||||||
|
data.Error(String::Format(TEXT("Failed to build Gradle project into package (result code: {0}). See log for more info."), result));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Copy result package
|
||||||
|
const String apk = data.OriginalOutputPath / (distributionPackage ? TEXT("app/build/outputs/apk/release/app-release-unsigned.apk") : TEXT("app/build/outputs/apk/debug/app-debug.apk"));
|
||||||
|
const String outputApk = data.OriginalOutputPath / EditorUtilities::GetOutputName() + TEXT(".apk");
|
||||||
|
if (FileSystem::CopyFile(outputApk, apk))
|
||||||
|
{
|
||||||
|
LOG(Error, "Failed to copy package from {0} to {1}", apk, outputApk);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
LOG(Info, "Output Android application package: {0} (size: {1} MB)", outputApk, FileSystem::GetFileSize(outputApk) / 1024 / 1024);
|
||||||
}
|
}
|
||||||
LOG(Info, "Output Android application package: {0} (size: {1} MB)", outputApk, FileSystem::GetFileSize(outputApk) / 1024 / 1024);
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -233,6 +233,44 @@ namespace FlaxEditor.Windows
|
|||||||
class Android : Platform
|
class Android : Platform
|
||||||
{
|
{
|
||||||
protected override BuildPlatform BuildPlatform => BuildPlatform.AndroidARM64;
|
protected override BuildPlatform BuildPlatform => BuildPlatform.AndroidARM64;
|
||||||
|
private bool _buildAAB = false;
|
||||||
|
|
||||||
|
[EditorOrder(21), Tooltip("Build an android app bundle instead of an APK"), EditorDisplay(null, "Build .aab")]
|
||||||
|
public bool BuildAAB
|
||||||
|
{
|
||||||
|
get => _buildAAB;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_buildAAB = value;
|
||||||
|
if (value)
|
||||||
|
{
|
||||||
|
|
||||||
|
var newDefines = new List<string>();
|
||||||
|
if (CustomDefines != null)
|
||||||
|
newDefines.AddRange(CustomDefines);
|
||||||
|
newDefines.Add("BuildAAB");
|
||||||
|
CustomDefines = newDefines.ToArray();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (CustomDefines != null)
|
||||||
|
{
|
||||||
|
if (CustomDefines.Contains("BuildAAB"))
|
||||||
|
{
|
||||||
|
var newDefines = new List<string>();
|
||||||
|
foreach (var define in CustomDefines)
|
||||||
|
{
|
||||||
|
if (!define.Equals("BuildAAB", StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
newDefines.Add(define);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CustomDefines = newDefines.ToArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Switch : Platform
|
class Switch : Platform
|
||||||
|
|||||||
Reference in New Issue
Block a user