Move Build .aab to Android platform settings and make it side-by-side
This commit is contained in:
@@ -364,7 +364,8 @@ bool AndroidPlatformTools::OnPostProcess(CookingData& data)
|
||||
}
|
||||
#endif
|
||||
const bool distributionPackage = buildSettings->ForDistribution || data.Configuration == BuildConfiguration::Release;
|
||||
if (data.CustomDefines.Contains(String(TEXT("BuildAAB"))))
|
||||
|
||||
if (platformSettings->BuildAAB)
|
||||
{
|
||||
// .aab
|
||||
{
|
||||
@@ -375,43 +376,39 @@ bool AndroidPlatformTools::OnPostProcess(CookingData& data)
|
||||
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/bundle/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;
|
||||
}
|
||||
LOG(Info, "Output Android application package: {0} (size: {1} MB)", outputAab, FileSystem::GetFileSize(outputAab) / 1024 / 1024);
|
||||
else
|
||||
LOG(Info, "Output AAB Android application package: {0} (size: {1} MB)", outputAab, FileSystem::GetFileSize(outputAab) / 1024 / 1024);
|
||||
}
|
||||
else
|
||||
|
||||
// .apk
|
||||
{
|
||||
// .apk
|
||||
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)
|
||||
{
|
||||
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);
|
||||
data.Error(String::Format(TEXT("Failed to build Gradle project into package (result code: {0}). See log for more info."), result));
|
||||
return true;
|
||||
}
|
||||
LOG(Info, "Output Android application package: {0} (size: {1} MB)", outputApk, FileSystem::GetFileSize(outputApk) / 1024 / 1024);
|
||||
}
|
||||
// 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 APK application package: {0} (size: {1} MB)", outputApk, FileSystem::GetFileSize(outputApk) / 1024 / 1024);
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -233,45 +233,6 @@ namespace FlaxEditor.Windows
|
||||
class Android : Platform
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (CustomDefines != null && CustomDefines.Contains("BuildAAB"))
|
||||
return;
|
||||
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
|
||||
|
||||
@@ -108,6 +108,12 @@ API_CLASS(sealed, Namespace="FlaxEditor.Content.Settings") class FLAXENGINE_API
|
||||
API_FIELD(Attributes="EditorOrder(500), EditorDisplay(\"General\")")
|
||||
TextureQuality TexturesQuality = TextureQuality::ASTC_Medium;
|
||||
|
||||
/// <summary>
|
||||
/// Whether to build android app bundle (aab) side by side with apk.
|
||||
/// </summary>
|
||||
API_FIELD(Attributes="EditorOrder(500), EditorDisplay(\"General\", \"Build .aab\")")
|
||||
bool BuildAAB;
|
||||
|
||||
/// <summary>
|
||||
/// Custom icon texture to use for the application (overrides the default one).
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user