Bluebonnet BNA
This is an implementation of a subset of the XNA 4.0 libraries for use with Bluebonnet to build games for Android.
Bluebonnet is an Android-compatible, light-weight, partial implementation of the .NET platform on top of the Java Virtual Machine. With Bluebonnet BNA, you can develop on Windows in C# or F# with the XNA libraries, and export to Android Java without any dependencies on native code libraries. But please note that Bluebonnet BNA does not aim for 100% compatibility with either .NET or XNA.
Building
-
Download and build the
Bluebonnet
compiler and its runtime library,Baselib.jar
. For instructions, see Bluebonnet README. -
Download the FNA source code. Build by typing the following command in the repository directory:
-
MSBuild FNA.csproj -p:Configuration=Release
-
If the build is successful, the file
FNA.DLL
will be generated in thebin/Release
sub-directory of the repository directory.
-
-
Download this BNA project and build it by typing the following command in the repository directory:
-
MSBuild BNA -p:Configuration=Release -p:ANDROID_JAR=/path/to/Android.jar -p:BLUEBONNET_EXE=/path/to/Bluebonnet/executable -p:FNA_DLL=/path/to/FNA.DLL
-
The
ANDROID_JAR
property specifies the full path to anAndroid.jar
file from the Android SDK distribution.BNA
requires Android SDK version 18 or later. -
The
BLUEBONNET_EXE
property specifies the full path to the Bluebonnet compiler that you built in an earlier step. -
The
FNA_DLL
property specifies the full path to the FNA.DLL that you built in an earlier step. As noted earlier, this path should be(FNA_DIR)/bin/Release/FNA.dll
. -
If the build is successful, the file
BNA.jar
will be generated in the.obj
sub-directory of the repository root directory.
-
Building the Demo
An example application Demo1
is provided, which demonstrates some XNA functionality in C# and F#. It can be built using Visual Studio (solution file Demo1.sln
), or from the command line:
-
Type
nuget restore Demo1
to restore packages using nuget. -
Type
msbuild Demo1 -p:Configuration=Release -p:Platform="x86"
-
Test the program:
.obj\Demo1\Release\Demo1.exe
. (Note that this will create the directorySavedGames\Demo1
in theDocuments
directory.) -
To convert the built application to an Android APK, type the following command: (Note that this is a single-line command; line breaks were added for clarity.)
-
MSBuild MakeAPK.project
-p:INPUT_DLL=.obj\Demo1\Release\Demo1.exe
-p:INPUT_DLL_2=.obj\Demo1\Release\Demo1FSharp.dll
-p:INPUT_DLL_3=.obj\Demo1\Release\FSharp.Core.dll
-p:CONTENT_DIR=.obj\Demo1\Release\Content
-p:ICON_PNG=Demo1\Demo1\GameThumbnail.png
-p:ANDROID_MANIFEST=Demo1\AndroidManifest.xml
-p:KEYSTORE_FILE=.\my.keystore
-p:KEYSTORE_PWD=123456
-p:APK_OUTPUT=.obj\Demo1.apk
-p:APK_TEMP_DIR=.obj\Demo1\Release\TempApk
-p:EXTRA_JAR_1=.obj\BNA.jar
-p:EXTRA_JAR_2=\path\to\Bluebonnet\Baselib.jar
-p:BLUEBONNET_EXE=\path\to\Bluebonnet.exe
-p:ANDROID_JAR=\path\to\Android\platforms\android-XX\android.jar
-p:ANDROID_BUILD=\path\to\Android\build-tools\30.0.2 -
Make sure to specify the right paths for the Bluebonnet compiler (via the
BLUEBONNET_EXE
property), the Baselib support library (via theEXTRA_JAR_2
property), the Android.jar file (via theANDROID_JAR
property) and the Android build-tools directory (via theANDROID_BUILD
property). -
The parameters are detailed at the top of the MakeAPK.project file. See also the comments in the AndroidManifest.xml file, and comments throughout the
Demo1
source files. -
If the build is successful, the file
Demo1.apk
will be generated in the.obj
sub-directory of the repository root directory.
-
-
The batch file
build_demo.bat
runs the steps discussed in this "Building the Demo" section. -
Install the built APK to an Android device:
\path\to\Android\platform-tools\adb install -r .obj\Demo1.apk