Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] Fix UnityThemeSelector error due to missing files in unityLibrary/src/android/res #894

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,18 @@ public class Build : EditorWindow
public static void DoBuildAndroidLibraryDebug()
{
DoBuildAndroid(Path.Combine(APKPath, "unityLibrary"), false, false);

// Copy over resources from the launcher module that are used by the library
Copy(Path.Combine(APKPath + "/launcher/src/main/res"), Path.Combine(AndroidExportPath, "src/main/res"));
}

[MenuItem("Flutter/Export Android (Release) %&m", false, 102)]
public static void DoBuildAndroidLibraryRelease()
{
DoBuildAndroid(Path.Combine(APKPath, "unityLibrary"), false, true);

// Copy over resources from the launcher module that are used by the library
Copy(Path.Combine(APKPath + "/launcher/src/main/res"), Path.Combine(AndroidExportPath, "src/main/res"));
}

[MenuItem("Flutter/Export Android Plugin %&p", false, 103)]
public static void DoBuildAndroidPlugin()
{
DoBuildAndroid(Path.Combine(APKPath, "unityLibrary"), true, true);

// Copy over resources from the launcher module that are used by the library
Copy(Path.Combine(APKPath + "/launcher/src/main/res"), Path.Combine(AndroidExportPath, "src/main/res"));
}

[MenuItem("Flutter/Export IOS (Debug) %&i", false, 201)]
Expand Down Expand Up @@ -238,6 +229,9 @@ private static void DoBuildAndroid(String buildPath, bool isPlugin, bool isRelea
SetupAndroidProject();
}

// Copy over resources from the launcher module that are used by the library, Avoid deleting the existing src/main/res contents.
Copy(Path.Combine(APKPath + "/launcher/src/main/res"), Path.Combine(AndroidExportPath, "src/main/res"), false);

if (isReleaseBuild) {
Debug.Log($"-- Android Release Build: SUCCESSFUL --");
} else
Expand Down Expand Up @@ -450,9 +444,9 @@ private static void BuildIOS(String path, bool isReleaseBuild)


//#region Other Member Methods
private static void Copy(string source, string destinationPath)
private static void Copy(string source, string destinationPath, bool clearDestination = true)
{
if (Directory.Exists(destinationPath))
if (clearDestination && Directory.Exists(destinationPath))
Directory.Delete(destinationPath, true);

Directory.CreateDirectory(destinationPath);
Expand Down