I am unable to run my game in android without including my source code in the assets folder. The documentation says I should use --main-pack <pck_or_zip_filepath_relative_to_assets_dir> but after exporting my game to the assets folder as game.pck and setting the commandline to --main-pack game.pck I get the following error:
1: USER ERROR: Cannot open resource pack ‘game.pck’.
2: at: _setup (core/config/project_settings.cpp:534)
3: Error: Couldn’t load project data at path “.”. Is the .pck file missing?
4: If you’ve renamed the executable, the associated .pck file should also be renamed to match the executable’s name (without the extension).
5: Unable to setup the Godot engine! Aborting…
At this point I thought maybe the .zip will work but when doing that I get the following error:
1: USER ERROR: Condition “f.is_null()” is true. Returning: nullptr
2: at: godot_open (core/io/file_access_zip.cpp:51)
3: USER ERROR: Parameter “zfile” is null.
4: at: try_open_pack (core/io/file_access_zip.cpp:171)
5: USER ERROR: Cannot open resource pack ‘project.zip’.
6: at: _setup (core/config/project_settings.cpp:534)
7: Error: Couldn’t load project data at path “.”. Is the .pck file missing?
8: If you’ve renamed the executable, the associated .pck file should also be renamed to match the executable’s name (without the extension).
9: Unable to setup the Godot engine! Aborting…
Including all my game files in the assets dir without using --main-pack works but I would prefer not contain all my game code there.
I export my godot project in windows platform and excute
“Godot_Demo.console.exe Godot_Demo.pck” , it works .
But in android platform , I don’t know how to embed the .pck or .zip if I do not override the getCommandLine() function. If you don’t mind, could you show me your sample code?
Thank you so much
The sample app provided by official is that put all godot code and art assets in src/main/assets, but actually I don’t want to expose my godot code.I followed the document and found that it is possible to create the Godot project in a separate directory and export it as a .pck file. Then put the .pck file exported into src/main/assets.
However, after my continuous attampts , I finailly succeeded. My code is as follows: @Override
public List getCommandLine() {
return List.of(“–main-pack”,“res://game.pck”);
}
There is a commandline/extra_args option in Android Export Preset. It is more convenient to set main pack option there.
BTW, how do you run the gradle build after repalcing the assets files? I tried to run gradle from command line, but it requires a lot of options. All the options are generated by Godot Android Export.