Tutorial: Creating your first Unity Android App

This is a quick, step by step guide to creating a simple spinning cube app for Android using Unity. This tutorial is for windows but other then the install instructions it should work for other platforms. By the end of this tutorial you will have created an app that displays a red spinning cube on a blue background on your Android device.

Setup Unity
You will need Unity AND the Android feature to create the app. Unity basic is free and the Android feature is currently free till the 8th April 2012 (which saves you $400). Download the installer from here and get your license from here.

Install Unity and register it using your license key which should have been emailed to you.

Setup the Android SDK
To create an Android app you need to install the Android SDK, which can be downloaded from here. I have the SDK installed to c:\android-sdk-windows

Once the SDK is installed you need to add the Android 2.1 (API level 7) package. Run the SDK Manager and use it to download the API level 7 packages. See here for more info.

Lastly, you will need to install the USB device drivers for your Android device. Whilst it is possible to use the Android Emulator its performance is pretty bad (especially when emulating tablets) so you are much better off testing on a real device. If you are using a “Nexus” device you can install USB drivers using the SDK Manager, otherwise search the web for your devices drivers.

To test that everything is set up, plugin in your device, open a cmd prompt and run the following commands :

cd \android-sdk-windows\platform-tools
adb devices

Your plugged in device should be listed. You may have to enable USB debugging for your device. Go to Settings -> Applications -> Development and turn on USB debugging.

Creating the app
Start Unity and select File -> New Project to create a new project, name the project RedCube.

In the drop-down box in the upper right of the screen make sure 4 Split is selected.

Create the cube
From the GameObject menu select Create Other and then select Cube. Make sure that Cube is selected in the Hierarchy panel (3rd panel along the top of the screen), then in the Inspector panel (far right panel) set the following values for the cube:

  • Position: x = 0, y = 0, z = 0
  • Rotation: x = 0, y = 45, z = 45
  • Scale: x = 2, y = 2, z = 2

Position the camera
Select the Main Camera  in the Hierarchy panel and set the following properties for the camera in the Inspector panel:

  • Position: x = 0, y = 0, z = -5

Add a light
From the GameObject menu, select Create Other and then Point light. Set the following properties for the light:

  • Position: x = 0, y = 0, z = -5

Test the scene
Click on the Play button (top center of the screen). You should now see the lower left panel switch to the Game tab and you should see a white cube on a blue background.

Press the Play button again to stop the game.

Note this important! Unity allows you to make changes whilst the game is running but these changes are lost as soon as you stop the game running. This is great for debugging but is an easy way to lose you changes :)

Save your project
Speaking of losing your work, now is a good time to save your project. Select File -> Save Scene, enter RedCubeScene as the name for the scene when prompted. Then select File -> Save Project to save the project. Remember to save your work regularly.

Making the cube red
Right click in the Project panel (3rd along the bottom) and then select Create -> Material, name it RedMat. In the Inspector window click on the white color block next to Main Color and then select a red color from the color picker. Drag the RedMat material from the Project window onto Cube  in the Hierarchy window. The cube should now turn red in the various scene windows.

Making the cube spin
In Unity scripts are used to add behavious to objects and to create the logic of your game. We will use a script to make the cube spin.

Right click in the Project panel and select Create -> C# Script, name it Spin.

In the Inspector window click the Open button, give it a moment for the MonoDevelop IDE to launch. You should see a code editor window. Modify the code to read as follows:

using UnityEngine;
using System.Collections;

public class Spin : MonoBehaviour {
    // Use this for initialization
    void Start () {

    // Update is called once per frame
    void Update () {
        // rotate at 90 degrees per second
        transform.Rotate(Vector3.up * Time.deltaTime*90);

Save the code (press Ctrl+S) and then switch back to the Unity editor.

Drag the Spin script from the Project window on to Cube in the Hierachy window.

Press the Play button. You should now see a red cube spinning in the Game window. Press Play again to stop the game.

Building the app
Now that we have the app completed, we need to build it.

Select Edit -> Project Settings -> Player

In the Inspector window under the Per-Platform Settings click on the tab with the Android icon (3rd tab along).

In the Other Settings section change the following values:

  • Bundle Identifier = com.rabidgremlin.tut.redcube
  • Minimum API Level = Android 2.1 ‘Eclair’ (API Level 7)

Now, select File -> Preferences and then select the External Tools section. Click on the button next to Android SDK location and select the root folder of your Android SDK install (c:\android-sdk-windows in my case).

Next plug-in your device.

Now, select File -> Build & Run, this will open the Build Settings window. Select  Android under platform and then click on the Build & Run button, when prompted for a name for the .apk file enter in RedCube.

A build dialog will pop up and you will see the app being built, then you will see a message about the app getting pushed to your device.

Have a look at your device, you should see the RedCube app starting up, followed by a red cube spinning on a blue background.

Congratulations you have created your first Unity Android app !

What next?
First off go and complete the 3D platform game tutorial. This will give you a good understanding of how Unity works. Also check out the very comprehensive documentation and the very helpful community.

Now go nuts :)

Update: If you are interested in creating 2D games with Unity check out my Dev Diary for my game Word War III

29 comments on “Tutorial: Creating your first Unity Android App”

  1. Shirley says:

    Hi, there, I’m a new developer in Unity and I want to try to make a simple game Unity for Android. But since Android have many type of screen, I’m confused in adjusting the screen to fit into many screens like that. Do you know how to do it?

  2. Buchiri says:

    Awesome TUT

  3. Randy says:

    Cool, thanks!

    Super simple.

  4. Melissa says:

    Thanks for the basic tut! Great intro project! This was my very first app tutorial so I didn’t have the Development Option. I had to gain Development status on the Android device to make the necessary adjustments to the USB settings. On my Android device I had to go to About Tablet, and tap on the Build Number until it allowed the Development option under Settings. Then I was able to fly through it. Thank you again!

  5. Diego Ribeiro says:

    After 3 hours installing goddamn sdks, I see a red cube spinning on my tablet screen.

    Joy of joys. Thank you! Seriously. =)


  6. tahmiid says:

    thanks a lot :D :D

  7. fffabs says:

    You are a genius!
    I can confirm this works great on my Nexus 4 with Jellybean 4.2.2 and Unity 4.0.1f2 compiled in Win8 x64. THAAAANK YOU!

  8. sunil panwar says:

    hi, i m using unity 4 , whenever create a .apk file using unity, and then install on android phone that is not install. and if it run with android emulator it generates error. i follow all the steps which is mentioned in this tutorial.

    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.rabidgremlin.tut.redcube/com.unity3d.player.UnityPlayerNativeActivity}: java.lang.IllegalArgumentException: No configs match configSpec
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
    at android.app.ActivityThread.access$600(ActivityThread.java:123)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:4424)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
    at dalvik.system.NativeStart.main(Native Method)
    Caused by: java.lang.IllegalArgumentException: No configs match configSpec
    at com.unity3d.player.w.a(Unknown Source)
    at com.unity3d.player.w.d(Unknown Source)
    at com.unity3d.player.w.a(Unknown Source)
    at com.unity3d.player.w.(Unknown Source)
    at com.unity3d.player.x.(Unknown Source)
    at com.unity3d.player.UnityPlayer$24.(Unknown Source)
    at com.unity3d.player.UnityPlayer.a(Unknown Source)
    at com.unity3d.player.UnityPlayer.init(Unknown Source)
    at com.unity3d.player.UnityPlayerNativeActivity.onCreate(Unknown Source)
    at android.app.Activity.performCreate(Activity.java:4465)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
    … 11 more

    so. how to overcome from it.

  9. amit k says:

    That was really awesome tut. I have made android apps but never games. I want to make 3d apps for android. I have unity basic version but cannot purchase unity android plugin. I request you to clarify following doubt. My question is what is the purpose of android plugin ? is it required to build the app or it is just for importing the app to android platform ? I am asking this because I am thinking to make my app in the unity desktop version and when everything is complete then buy android license. Is it possible to work this way ? Thanks in advance for your time.

  10. Tony says:

    Cool tutorial to begin ! My first steps with Unity and Android.

    The Redcube is spinning on my tablet and phone :)

  11. XN4k3D says:

    What i can implemente auto display for androids diferente models?

  12. sam says:

    what should be the code for pc to spin in my pc ???

  13. jsa says:

    I will gonna try this….Im a newbee..so plz teach me how to use the unity….

  14. SarveshSvaran says:

    Please… Help me…. I installed the android sdk (4.2.2) now…. when i try to build it …. it says sdk cannot be found…… but i gave the correct path(pretty sure)…… please help me…. >_<

  15. Mike says:

    Hey, very nice tutorial.. really helpful!

  16. Jerry says:

    Thanks… awesome tutorial!!!

  17. Quan says:

    Very useful tutorial! Thanks very much!
    The red cube is spinning now~~~

  18. Kuba says:

    Cool Tut. Thanks a lot. Works like a charm on HTC Desire and Unity4. But HTC sync must be uninstalled, otherwise the following error messages appears: “error buildin player ArgumentOutOfRangeException cannot be negative”

  19. rob says:

    Excellent tutorial my friend! you have great way of explaining so almost anyone can follow along. I hope you make more tuts for us. Keep up the awesome work

  20. Nusrat says:

    Thanks for the nice tutorial .
    So whenever you are trying to spin the cube you have used a script .
    Can we write this script in Java ?
    Unity supports JavaScript, C#, Boo only , I am a Java developer , Is there any scope of using Java in Unity ?

    • jack says:

      Well in theory you could use JNI and call out to Java via a native DLL. However I suspect you need the Pro version of Unity, it will only work on the Desktop and is likely to be very slow. If you are a Java dev then I’d suggest you use C# its pretty close to Java so you shouldn’t have any problems.

  21. corpsinhere says:

    I think there is a tiny error:
    “Now, select File -> Preferences and then select the External Tools section.”
    Should be (at least in Unity4 4.2.2f1)
    Now, select Edit -> Preferences and then select the External Tools section.
    Also, thanks for the great tutorial – when I saw the red spinning cube on my phone I almost peed myself with happiness :).

  22. […] Tutorial for Setting up Unity for building an Android game […]

  23. adi says:

    Great tutorial thanks

  24. UdiOshi says:

    Great tutorial! went smooth with no errors during the steps, well done!

  25. […] a fair bit of traffic (about 5000 unique visitors a month) and contains popular posts such as my Creating your first Unity Android App post which averages about 150 views a […]

  26. Freddy says:

    EXACTLY what I needed! Thanks mate!

  27. ReSY says:

    Thank you for useful tutorial. I do all steps and get result! Thank you! Nice tutorial.

leave a comment

(will not be published)