Command-line build for Android strips out used assets like png

We are using Unity commandline to build our app for android platform. Build succeeds but doesn’t have assets (like pngs etc.) used by app and hence, it doesn’t work on HMD.

Unity commandline:


./Unity -projectPath /Users/me/git/MyApp -quit -batchmode -executeMethod PerformBuild -path /Users/me/builds/ -keystorePass XYZ' -keyaliasPass 'XYZ'

Build method:


private static void PerformBuild()
{
	string path = GetArg("-path");
	PlayerSettings.keyaliasPass = GetArg("-keyaliasPass");
	PlayerSettings.keystorePass = GetArg("-keystorePass");
	string[] scenes = new string[] { "Assets/Scenes/Scene.unity" };
	BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions();
	buildPlayerOptions.scenes = scenes;
	buildPlayerOptions.locationPathName = path + "/" + “MyApp.apk”;
	buildPlayerOptions.target = BuildTarget.Android;
	buildPlayerOptions.options = BuildOptions.None;
	BuildPipeline.BuildPlayer(buildPlayerOptions);
}

Any help will be appreciated. Thanks!

  1. First thing is you need to move the resources from the editor
    so it goes something like this.

FileUtil.MoveFileOrDirectory("Assets/Editor/Resources/MC_VERSION", "Assets/Resources/MC_VERSION"); FileUtil.MoveFileOrDirectory("Assets/Editor/Resources/MC_VERSION.meta", "Assets/Resources/MC_VERSION.meta");

  1. You have to change also the manifest
    Something like this:
    hsFileIO.CopyFile (szFileFullPath_Jar + _filename, szAfterJarFolder + "libs\\" + _filename);

Thats all you need . And thats what you are missing.

Hi @PaulKevin, thanks for your reply.

I don’t have any pngs/jpgs in Assets/Editor/Resources folder. They are all scattered in different folders and android build process doesn’t include those files. When I invoke the same build command via menu item in Unity IDE, those pngs/jpgs are being included in apk. Any insight will be helpful.