Creating Buildbox android APK without Eclipse (part 1/2) [Buildbox like a boss serie]
If you already created games with buildbox, you maybe don’t want to open eclipse each time you want to build your Android APK.
or you just don’t like eclipse and don’t want to install it.
if this is your case, this article may interest you.
This is the first article of “Buildbox like a boss” serie, so let me know what do you think about it, and how I can enhance it.
Prerequisties
- Windows environment
- Android environment (Java, SDK, Ant)
- System configuration (Paths)
Checking and fixing the environment.
To check if everything is correctly installed, open a command prompt window and type “adb version” (without quotes)
you should see something like this
if you get an error saying that he command is not recognized it means that android SDK is not correctly installed, you need to install it.
now just to make sure that everything is fine, type the following command .
1 |
echo %ANDROID_HOME% |
and finally type
1 |
ant -v |
if you get a message saying that the command is not recognized, you should install ANT.
(follow this tutorial to install ANT)
if your environment is correctly configured you can move to the next step.
Creating build script
Now we’ll create a script to automate the APK creation, then we’ll add it to windows explorer context menu to make it easier to use.
Create a folder called c:\bbscripts\
in this folder create a file called apkbuild.bat, edit it with your prefered text/code editor and copy past the lines below
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
echo off echo off set argfolder=%1 set argmode=%2 shift shift echo ====[BBBuilder v1.0]==== echo * restarting adb daemon ... adb kill-server echo * cleaning project ... call ant clean -f %argfolder%\build.xml echo * updating project ... call "%ANDROID_HOME%\tools\android.bat" update project -p %argfolder% call "%ANDROID_HOME%\tools\android.bat" update project -p %argfolder%\libs\google-play-services_lib echo * building ... call ant %argmode% install -f %argfolder%\build.xml echo [build finished] pause |
Let’s test the script
assuming you exported and android project from buildbox to c:\bbgames\exports\MyGame
(MyGame is the folder containing a subfolder called android).
open a command prompt window and type
1 |
cd c:\bbgames\exports |
1 |
c:\bbscript\apkbuild.bat MyGame\android debug |
this will build and install the game into the attached device.
if this is working then you can already build your games using this script, but let’s make it more user friendly 🙂
Creating shell extensions
Shell extensions will add Explorer right click menu entries to make apk creation easier
inside c:\bbscripts folder
create a file called apkbuild-install.reg and edit it with the following content.
1 2 3 4 5 6 7 8 9 10 |
Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\Directory\shell\BBBuilder] "Subcommands"="" [HKEY_CLASSES_ROOT\Directory\shell\BBBuilder\Shell\APKBuild] "MUIVerb"="Build Debug APK" [HKEY_CLASSES_ROOT\Directory\shell\BBBuilder\Shell\APKBuild\command] @="\"C:\\bbscripts\\apkbuild.bat\" \"%1\" debug" |
create another file called apkbuild-uninstall.reg and edit it with the following content
1 2 3 |
Windows Registry Editor Version 5.00 [-HKEY_CLASSES_ROOT\Directory\shell\BBBuilder] |
Double click on apkbuild-install.reg, you’ll be prompted to accept changes made to windows registry, Accept them.
this will add an entry called “BBBuilder” to explorer right click menu.
this entry will show when you click any folder, but is only usable with android export folder from buildbox
at this stage you can right click android folder where your game is exported and choose, BBBuilder > Build Debug APK

this will run the script we created before and will build and install the APK in the attached device.
if you don’t like the shell extension and prefer using command line only, you can remove it at any time by double clicking apkbuild-uninstall.reg .
Next
This article showed how to create and run an androit APK without using/installing eclipse.
the created APK here is for testing only (a debug version), since it’s not signed with your keystore, you can’t publish it for large public.
in the next article I’ll explain how to create a release APK package, ready for publishing on google play store.
and we will create a shell extension for it as well.