This is a port of the sm64ex-coop
multiplayer mod for Super Mario 64 to Android using SDL2 with OpenGL ES 2.0.
To compile only libmain.so
(the minimum required) and use precompiled libSDL2.so
, classes.dex
, AndroidManifest.xml
, etc, follow the guide here!
[The section below is for advanced users - beginners should choose one of the other build methods, like minimal from Android or full from Windows]:
To compile fully on Android, including Java and SDL2 components, first follow the instructions here up to and including step 16, then clone this repository and perform a partial build, whose binaries will not be used in your complete build, but which has the side effect of extracting the assets and generating some required source files from them, steps not currently called from the gradle
+ ndk-build
build system:
git clone --recursive https://github.com/robertkirkman/sm64ex-coop-android-base.git
cd sm64ex-coop-android-base/app/jni/src
cp /storage/emulated/0/baserom.us.z64 .
make -j$(nproc)
Then, use this guide on this repository. Tips:
-
Requires Android 9+
-
Ignore references to
cmake
in that guide, since this project usesndk-build
instead ofcmake
-
Make sure to keep track of what files you extract to which places, and edit the paths in the configuration files and commands you copy from the guide to match where you placed the files
-
In addition to the "Replace the aapt2" step as described in that guide, I also have to replace another cached copy of
aapt2
with the same binary that had to be inserted intoaapt2-7.1.0-7984345-linux.jar
. Example:
cp ~/opt/aarch64/build-tools/aapt2 /data/data/com.termux/files/home/.gradle/caches/transforms-3/e2966ab490263982a29d42a1b79481d9/transformed/aapt2-7.1.0-7984345-linux/aapt2
- Use
gradle assembleDebug
instead ofgradle build
. Your.apk
will be inapp/build/outputs/apk/debug/
when the full build completes.
You will need at least 12 GB of free space on your
C:\
drive to install all the dependencies needed here
- Go to the MSYS2 Releases page, click "Assets" under the newest release, and click the link that looks like "
msys2-x86_64-XXXXXXXX.exe
":
- Click the file in your browser's downloads popup when it finishes downloading:
- Click "More info" in the Windows Defender SmartScreen popup, then click "Run anyway":
- Click "Next" twice in the MSYS2 installer, then click "Install", wait for the installation to complete, then click "Next", then uncheck "Run MSYS2 Now", then click "Finish":
- Open the Start Menu and search "MSYS2 MINGW64", then click on it. This is the MSYS2 with the BLUE icon.
- Run the following command in the MSYS2 window. You can use the button in the right side of the code block to copy it from GitHub, then right click in the MSYS2 window and click "Paste" to paste it, then press Enter to run it:
pacman -Syuu --noconfirm
- If the MSYS2 window closes, repeat steps 5 and 6 until it no longer closes. Then, run this command in the MSYS2 window to install native build dependencies:
pacman -S --noconfirm unzip make git mingw-w64-x86_64-gcc python3
- Next, run these commands to create a new folder (
C:\g\
) and change working directory to it (IMPORTANT: it must be in this exact folder), clone the repository, and navigate to thesm64ex-coop-android-base/app/jni/src
directory:
cd /c
mkdir g
cd g
git clone --recursive https://github.com/robertkirkman/sm64ex-coop-android-base.git
cd sm64ex-coop-android-base/app/jni/src
- Leave the MSYS2 window open for now and open a File Explorer window, then click "This PC" in the left column:
- Open drive
C:
and navigate toC:\g\sm64ex-coop-android-base\app\jni\src
:
- Copy your
baserom.us.z64
into this folder. If you don't already have abaserom.us.z64
, here's the guide to obtain one:
- Go back to the MSYS2 window and execute a native build using this command. This will take a long time:
If you get an error like
Error reading codebook
orYou should specify a coefficient codebook
, just usemake clean
and keep trying again until it works, that only happens sometimes on Windows and I don't know what causes it
HEADLESS=1 TOUCH_CONTROLS=1 TARGET_FOSS=0 make
- Go to the Android Studio website and click "Download Android Studio":
- Check the box to agree to the terms and conditions, then click the download link:
- Repeat step 2 but for the Android Studio installer, then click "Next" 3 times and "Install" once, and wait for the installation to complete:
- Click "Next", then "Finish", then click "OK" when this box appears:
- When this window appears, click "Don't send", then click "Next" four times:
- When you see this, click "Accept", then click either one of the "Intel" buttons to the left and click "Accept" again, then click "Finish" and wait for the installation to complete:
- When the "Finish" button becomes clickable again, click it:
- Then, click "Open" when you see this window:
- Navigate to
C:\g\sm64ex-coop-android-base
, then click "OK":
- Click "Trust Project" when you see this, then wait for the project to open:
- When you see the Windows Defender Firewall popup, click anything because you do not need to use ADB just to build - you can copy the
.apk
to your device over MTP later:
- Wait for this progress bar in the bottom right to stop loading. This will take a long time:
- When the progress bar disappears, the hammer icon in the top center will turn green. Click it, then wait for a progress bar in the same place as step 24 to finish loading again. This will take a long time:
- Open File Explorer and navigate to
C:\g\sm64ex-coop-android-base\app\build\outputs\apk\debug
. If the build was successful, theapp-debug.apk
will be here, and you can copy it to your Android device and install it there. Do not share, remember the.apk
contains assets! Treat it the same way you would asm64.us.f3dex2e.exe
!
For more information and follow-up steps for what to do on-device after obtaining the
.apk
, check out the submodule repository READMEs.
Assumes general Arch Linux experience,
sudo
, an AUR helper, andmultilib
enabled.
Install dependencies:
yay -S base-devel jdk17-openjdk android-sdk-cmdline-tools-latest android-sdk-build-tools android-sdk-platform-tools android-platform python sdl2 glew readline
Source /etc/profile
to set ANDROID_SDK_ROOT
:
source /etc/profile
Set default JDK to java-17-openjdk
:
sudo archlinux-java status
sudo archlinux-java set java-17-openjdk
Make Android SDK installation path writable and accept all SDK licenses:
sudo -E chmod -R 777 $ANDROID_SDK_ROOT
sdkmanager --licenses
Clone the repository:
git clone --recursive https://github.com/robertkirkman/sm64ex-coop-android-base.git
cd sm64ex-coop-android-base
Copy in your baserom.us.z64
:
cp /path/to/your/baserom.us.z64 app/jni/src/baserom.us.z64
Perform native build:
cd app/jni/src
TOUCH_CONTROLS=1 make -j$(nproc)
cd -
Perform Android build:
./gradlew assembleDebug
Enjoy your apk:
ls -la app/build/outputs/apk/debug/app-debug.apk
Clone the repository:
git clone --recursive https://github.com/robertkirkman/sm64ex-coop-android-base.git
cd sm64ex-coop-android-base
Build Docker image:
docker build . -t sm64_android
Copy in your baserom.us.z64
:
cp /path/to/your/baserom.us.z64 app/jni/src/baserom.us.z64
Perform native build:
docker run --rm -v $(pwd):/sm64 sm64_android sh -c "cd /sm64/app/jni/src && TOUCH_CONTROLS=1 make -j$(nproc)"
Perform Android build:
docker run --rm -v $(pwd):/sm64 sm64_android sh -c "./gradlew assembleDebug"
Enjoy your apk:
ls -la app/build/outputs/apk/debug/app-debug.apk
If you want to customize the build with build options, you should make the native build with those options first (put them after the make
command like on normal repos), then before performing the Android build, edit app/jni/src/Android.mk
and enable the options you'd like.