- Home /
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!
Answer by Ginxx009 · Jan 12, 2018 at 02:09 AM
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");
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.
Answer by pankajknathani · Jan 12, 2018 at 06:09 AM
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.
Your answer
Follow this Question
Related Questions
How to correct the errors with my android build 0 Answers
Android app opens "App Info" instead of launching app 0 Answers
CommandInvokationFailure: Gradle build failed. 1 Answer
Android Error building Player: CommandInvokationFailure: Failed to re-package resources 1 Answer
Unity Android Studio project export 0 Answers