godot icon indicating copy to clipboard operation
godot copied to clipboard

Unable to perform a headless Android build (with custom builds) without first opening the GUI

Open kjav opened this issue 5 years ago • 11 comments

Godot version: 3.2.1+

OS/device including version: Android

Issue description: The headless version of godot can be used to export projects without opening the editor. This is important for Continuous Delivery & automation of development. Since Godot 3.2.1, we have been able to use a custom android export when exporting our Android games. In a newly checked out project, one has to go to the Project>"Install Android Build Template" in order to begin exporting for android. However, there is no way to do this with the headless version of godot. Because of this, you are unable to perform an initial build of a godot Android game with the headless version, without first opening it in the GUI.

I think there should be a godot command to run this gradle setup from the command line, to keep this tool consistent.

kjav avatar Apr 29 '20 14:04 kjav

Can't the build template be downloaded and extracted using curl and unzip? The URL may be nontrivial to figure out though.

See also #35600.

Calinou avatar Apr 29 '20 14:04 Calinou

I don't think this is the same thing, even though the names are confusingly similar. The build template I'm referring to is the 'build' directory in the 'android' subdirectory. More information here.

kjav avatar Apr 29 '20 14:04 kjav

While I agree it would be nice with a command line way of doing the "install Android build template", the only thing it does AFAIK is unzipping android_source.zip into the android/build folder.

Myran avatar Apr 29 '20 17:04 Myran

I guess that's a reasonable alternative for any automated system to implement. Thanks for the help, @Myran . For future people with the same problem: The android_source.zip is inside the export templates.

kjav avatar May 01 '20 14:05 kjav

This is now an issue again in Godot 3.2.2, because extra files are needed to perform a build successfully (from what I can tell, it needs a "plugins" directory and a .build_version file containing the godot version string). Whilst I can add this manually to a build tool it does demonstrate the need for a command line option, as these requirements could change in the future and break the tools which have worked around this issue.

I believe this should be classed as a bug as you are meant to be able to compile using the headless version of godot, and this doesn't allow you to do that.

I.e. godot --export Android fails for a valid project which can be build using the GUI.

kjav avatar Feb 04 '21 16:02 kjav

@kjav Thanks for the feedback! At the moment, there are no plans to alter the structure of a custom Android build, so the changes to your build tool should be good for a while.

But I do see your point, and agree it would be a good idea to automate that process from the command line. I can't give a firm timeline on when this will be implemented, but contributions are welcomed!

m4gr3d avatar Feb 08 '21 23:02 m4gr3d

Hey, I wanted to tackle this as my first godot contribution and narrowed down all the locations in need for a change to implement the requested feature. Before I raise an PR I wanted to make sure, that my solution would actually implement the enhancement. One open question beforehand: Should I implement this feature on the master branch or the 3.4 branch, since this issue is assigned to the 3.5 milestone?

Current behavior

Executing godot --path /path/to/project --export-debug "Android" fails, if the project was not opened in editor on the build machine and "Project -> Install Android Build Template..." was not clicked. This menu button creates the directoy "res://android" with the following contents:

  • "/build" directory, in which the "android_source.zip" gets extracted into
  • "/plugins" directory, which is empty without further configuration
  • and ".build_version" file, which contains the godot version (f.e. "3.5.rc")

Desired behavior

The commands currently executed by clicking the menu button "Project -> Install Android Build Template..." should be available as command line argument. Proposed API: godot --path /path/to/project --export-debug "Android" --install-android-build-template [/path/to/android_source.zip] Where the path to "android_source.zip" can be specified optionally but will default to the default location of "Project -> Install Android Build Template...".

Did I miss something? Is there some aspect I didn't consider? Is the proposed API acceptable?

AntonioDell avatar Jul 24 '22 08:07 AntonioDell

Hey, I wanted to tackle this as my first godot contribution and narrowed down all the locations in need for a change to implement the requested feature. Before I raise an PR I wanted to make sure, that my solution would actually implement the enhancement. One open question beforehand: Should I implement this feature on the master branch or the 3.4 branch, since this issue is assigned to the 3.5 milestone?

Current behavior

Executing godot --path /path/to/project --export-debug "Android" fails, if the project was not opened in editor on the build machine and "Project -> Install Android Build Template..." was not clicked. This menu button creates the directoy "res://android" with the following contents:

  • "/build" directory, in which the "android_source.zip" gets extracted into
  • "/plugins" directory, which is empty without further configuration
  • and ".build_version" file, which contains the godot version (f.e. "3.5.rc")

Desired behavior

The commands currently executed by clicking the menu button "Project -> Install Android Build Template..." should be available as command line argument. Proposed API: godot --path /path/to/project --export-debug "Android" --install-android-build-template [/path/to/android_source.zip] Where the path to "android_source.zip" can be specified optionally but will default to the default location of "Project -> Install Android Build Template...".

Did I miss something? Is there some aspect I didn't consider? Is the proposed API acceptable?

Hi @AntonioDell , that sounds like a great first contribution to tackle! As someone who has had to work around the issue, I can confirm that that is how I have fixed the issue manually in the past.

kjav avatar Jul 24 '22 09:07 kjav

Hey @kjav , I created a PR in which I added the --android-template option to the cli. If you have some time, I'd appreciate your feedback on the code change. Does it solve your issue?

AntonioDell avatar Jul 24 '22 13:07 AntonioDell

As the other issue has been closed as duplicate, I copy-paste here my concern regarding the solution provided (which doesn't seem to work). Can you please help me to resolve the issue?

https://github.com/godotengine/godot/issues/78412#issuecomment-1597749567

The method mentioned in https://github.com/godotengine/godot/issues/35600#issuecomment-898908949 or in your comment above doesn't work.

I created an android folder within my main folder with the content of android_source.zip, I still read the error message:

ERROR: Cannot export project with preset "Android" due to configuration errors:
Android build template not installed in the project. Install it from the Project menu.

Here is the content of the game folder:

$ ls
AutoLoad		Materials		Themes			assets			icon.png
Design			Scenes			UI			default_bus_layout.tres	icon.png.import
ExternalVisuals		Shaders			addons			default_env.tres	project.godot
Game			SplashScreen		android			export_presets.cfg

And here is the content of the android folder:

$ ls android 
AndroidManifest.xml	build.gradle		gradle.properties	libs			src
assetPacks		config.gradle		gradlew			res
assets			gradle			gradlew.bat		settings.gradle

Do you have further indications please?

Can you please not close the issue until it is resolved? It will not only benefit myself but also all future users that will encounter this problem and search for an answer (so they won't have to open another issue, again and again).

AdrKacz avatar Jun 19 '23 21:06 AdrKacz

Has anyone figured out an approach to tackle this (using Godot 4.x)?

fabianPas avatar Oct 02 '24 13:10 fabianPas

Nothing?

valerioleite avatar May 15 '25 23:05 valerioleite

@ntngamedev as far as i can tell, the step of unzipping the contents of android_source.zip into android/build/ still functions. @AdrKacz seems to have unzipped into android directly, which may be the problem. Give it a try, it seems to work here.

ChristopheVandePoel avatar May 23 '25 15:05 ChristopheVandePoel