Closed cuong0993 closed 1 year ago
Thank you for the issue. I'll make a PR after 3.2.4 is released soon.
I do not have a lot of time these few weeks so doing all the changes together is easier.
Just wanted to share interest in this feature. I might add this myself in a couple of weeks if it's not done by then. Thank you for the project by the way!
@jfaz1 Out of curiosity, did you manage to get Mono exporting for work for Android?
Hey I also need this. How can I make this happen?
Is this going to get support?
Is this going to get support?
There is no ETA for implementing this, as nobody is currently working on this (and I don't use C# myself).
I built an image myself https://github.com/cuong0993/godot-mono-docker
@cuong0993 Hello friend, I must admit I'm not sure exactly how to use that. Would you mind giving me a brief explanation?
This is how I use it https://github.com/cuong0993/puzzle/blob/main/.github/workflows/main.yml .
@cuong0993 What is EXPORT_PRESETS secret, and do you not need to use the user and pass for your keystore? Is there anything custom I need to do in my android export preset that is different from the default Android presets provided in this repo?
This is my EXPORT_PRESETS. It contains keystore password so I keep it secret. I know godot can be configure keystore per IDE (all projects) but I prefer configure for each project.
@cuong0993 Did you delete or make those repositories private? I can't find your docker image or usage example you mentioned above.
Just make the repo public again.
Just make the repo public again.
Thank you! I forked and modified your docker repo. Had to go crazy with the yaml. Here's the final working result for exporting Android C# (game name redacted because it's for a client):
name: Export Android
on: [push, pull_request]
env:
LANG: "en_US.UTF-8"
GODOT_VERSION: 3.5.1
ADMOB_VERSION: 2.1.2
APK_NAME: MyGameName
jobs:
export-android:
name: android export
runs-on: ubuntu-latest
container:
image: forerunnergames/godot-mono:latest
steps:
- name: checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: copy editor settings to expected directory
run: |
mkdir -v -p ~/.config/godot
cp -v /root/.config/godot/editor_settings-3.tres ~/.config/godot/
- name: copy export templates to expected directory
run: |
mkdir -v -p ~/.local/share/godot/templates
cp -R /root/.local/share/godot/templates/${GODOT_VERSION}.stable.mono ~/.local/share/godot/templates/
- name: install & configure android build template
run: |
mkdir -v -p android/build
unzip -d android/build/ ~/.local/share/godot/templates/${GODOT_VERSION}.stable.mono/android_source.zip
touch android/build/.gdignore
echo ${GODOT_VERSION}.stable.mono > android/.build_version
echo "org.gradle.java.home=/usr/lib/jvm/java-11-openjdk-amd64" >> android/build/gradle.properties
- name: install & configure admob plugin
env:
ADMOB_ANDROID_APP_ID: ${{ secrets.ADMOB_ANDROID_APP_ID }}
run: |
mkdir -v -p android/plugins
wget https://github.com/Poing-Studios/godot-admob-android/releases/download/v${ADMOB_VERSION}/android-mono-template-v${GODOT_VERSION}.zip
unzip -d android/plugins/ android-mono-template-v${GODOT_VERSION}.zip
rm android-mono-template-v${GODOT_VERSION}.zip
sed -i "s,<\/activity>,<\/activity>\\n\\n <meta-data\n tools:replace=\"android:value\"\n android:name=\"com.google.android.gms.ads.APPLICATION_ID\"\n android:value=\"${ADMOB_ANDROID_APP_ID}\"\/>," android/build/AndroidManifest.xml
- name: configure release keystore
env:
ANDROID_RELEASE_KEYSTORE_BASE64: ${{ secrets.ANDROID_RELEASE_KEYSTORE_BASE64 }}
ANDROID_RELEASE_KEYSTORE_USER: ${{ secrets.ANDROID_RELEASE_KEYSTORE_USER }}
ANDROID_RELEASE_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_RELEASE_KEYSTORE_PASSWORD }}
run: |
echo $ANDROID_RELEASE_KEYSTORE_BASE64 | base64 --decode > release.keystore
echo $ANDROID_RELEASE_KEYSTORE_BASE64 | base64 --decode > android/build/release.keystore
mkdir -v -p build/android
sed 's@keystore/release=".*"@keystore/release="'release.keystore'"@g' -i export_presets.cfg
sed 's@keystore/release_user=".*"@keystore/release_user="'${ANDROID_RELEASE_KEYSTORE_USER}'"@g' -i export_presets.cfg
sed 's@keystore/release_password=".*"@keystore/release_password="'${ANDROID_RELEASE_KEYSTORE_PASSWORD}'"@g' -i export_presets.cfg
- name: export apk
run: |
godot -v --export "Android" build/android/$APK_NAME.apk
- name: upload artifacts
uses: actions/upload-artifact@v3
with:
name: MyGameName
path: build/android
Dockerfile:
FROM alpine as files
WORKDIR /files
RUN apk add -U unzip && rm -rf /var/cache/apk/*
ENV GODOT_VERSION "3.5.1"
ENV RELEASE_NAME "stable"
# This is only needed for non-stable builds (alpha, beta, RC)
# e.g. SUBDIR "/beta3"
# Use an empty string "" when the RELEASE_NAME is "stable"
ENV SUBDIR ""
RUN wget -O /tmp/godot.zip https://downloads.tuxfamily.org/godotengine/${GODOT_VERSION}${SUBDIR}/mono/Godot_v${GODOT_VERSION}-${RELEASE_NAME}_mono_linux_headless_64.zip
RUN unzip /tmp/godot.zip -d /tmp/godot
RUN mv /tmp/godot/* /files
RUN wget -O /tmp/godot_templates.tpz https://downloads.tuxfamily.org/godotengine/${GODOT_VERSION}${SUBDIR}/mono/Godot_v${GODOT_VERSION}-${RELEASE_NAME}_mono_export_templates.tpz
RUN unzip /tmp/godot_templates.tpz -d /tmp/godot_templates
RUN mv /tmp/godot_templates/* /files
RUN wget -O /tmp/android_sdk.zip https://dl.google.com/android/repository/commandlinetools-linux-8512546_latest.zip
RUN unzip /tmp/android_sdk.zip -d /tmp/android_sdk
RUN mv /tmp/android_sdk/* /files
FROM mono:latest
USER root
ENV DEBIAN_FRONTEND=noninteractive
ENV GODOT_VERSION "3.5.1"
ENV RELEASE_NAME "stable"
ENV ANDROID_SDK_PLATFORM 31
ENV ANDROID_BUILD_TOOLS 30.0.3
ENV ANDROID_HOME="/usr/lib/android-sdk"
RUN apt-get update && apt-get install -y --no-install-recommends \
unzip \
wget \
python \
openjdk-11-jdk-headless \
&& rm -rf /var/lib/apt/lists/*
COPY --from=files /files/Godot_v${GODOT_VERSION}-${RELEASE_NAME}_mono_linux_headless_64/Godot_v${GODOT_VERSION}-${RELEASE_NAME}_mono_linux_headless.64 /usr/local/bin/godot
COPY --from=files /files/Godot_v${GODOT_VERSION}-${RELEASE_NAME}_mono_linux_headless_64/GodotSharp /usr/local/bin/GodotSharp
COPY --from=files /files/templates /root/.local/share/godot/templates/${GODOT_VERSION}.${RELEASE_NAME}.mono
COPY --from=files /files/cmdline-tools ${ANDROID_HOME}/cmdline-tools/latest
ENV PATH="${ANDROID_HOME}/cmdline-tools/cmdline-tools/latest/bin:${PATH}"
RUN yes | ${ANDROID_HOME}/cmdline-tools/latest/bin/sdkmanager --licenses
RUN ${ANDROID_HOME}/cmdline-tools/latest/bin/sdkmanager "platform-tools" "build-tools;${ANDROID_BUILD_TOOLS}" "platforms;android-${ANDROID_SDK_PLATFORM}" "cmdline-tools;latest" "cmake;3.10.2.4988404" "ndk;21.4.7075529"
RUN keytool -keyalg RSA -genkeypair -alias androiddebugkey -keypass android -keystore debug.keystore -storepass android -dname "CN=Android Debug,O=Android,C=US" -validity 9999 \
&& mv debug.keystore /root/debug.keystore
RUN godot -e -v -q
RUN echo 'mono/builds/build_tool = 3' >> ~/.config/godot/editor_settings-3.tres
RUN echo 'export/android/android_sdk_path = "/usr/lib/android-sdk"' >> ~/.config/godot/editor_settings-3.tres
RUN echo 'export/android/debug_keystore = "/root/debug.keystore"' >> ~/.config/godot/editor_settings-3.tres
RUN echo 'export/android/debug_keystore_user = "androiddebugkey"' >> ~/.config/godot/editor_settings-3.tres
RUN echo 'export/android/debug_keystore_pass = "android"' >> ~/.config/godot/editor_settings-3.tres
RUN echo 'export/android/force_system_user = false' >> ~/.config/godot/editor_settings-3.tres
RUN echo 'export/android/timestamping_authority_url = ""' >> ~/.config/godot/editor_settings-3.tres
RUN echo 'export/android/shutdown_adb_on_exit = true' >> ~/.config/godot/editor_settings-3.tres
@cuong0993 @knightofiam This looks good, feel free to make PR if you would like it merged 👍
I'm also interested in this feature!
Note that Godot 4 doesn't support C# on Android yet, so a PR must target 3.x instead.
Hi,
I could not export android using godot mono. I checked that mono.Dockerfile do not have android installation like Dockerfile. Please consider to support export android in mono.Dockerfile.