Getting Started with Android Development
Manual     Reference     Scripting   
Unity Manual > Getting Started with Android Development

Getting Started with Android Development

Developing for Android

Building games for a device running Android OS requires an approach similar to that for iOS development. However, the device's hardware is not completely standardized, which raises issues that don't occur in iOS development. There are some feature differences in the Android version of Unity just as there are with the iOS version.

Setting up your Android Developer environment

Before you can run Unity Android games on the actual device, you'll need to have your Android developer environment set up. This involves downloading and installing the Android SDK with the different Android plaforms and adding your physical device to your system (this is done a bit differently depending on whether you are developing on Windows or Mac). This setup process is explained on the Android developer website, and there may be additional information provided by the manufacturer of your device. Since this is a complex process, we've provided a basic outline of the tasks that must be completed before you can run code on your Android device or in the Android emulator. However, the best thing to do is follow the instructions step-by-step from the Android developer portal.

Access Android Functionality

Unity Android provides a scripting APIs to access various input data and settings. You can find out more about the new scripting classes on the Android scripting page.

Exposing Native C, C++ or Java Code to Scripts

Unity Android allows you to call custom functions written in C/C++ directly (and Java indirectly) from C# scripts. To find out how to bind native functions, visit the plugins page.

Occlusion Culling

Unity Android includes support for occlusion culling, which is perfect for squeezing high performance out of complex scenes with many objects. To learn how occlusion culling works, visit the occlusion culling page.

Splash Screen Customization

If you want to customize the splash screen that appears when launching your game on the device, you should visit the splash screen customization page.

Troubleshooting

There are many reasons why your application may crash or fail to work as you expected. Look here to see how to troubleshoot on Android.

Reporting Crash Bugs on Android

Before submitting a bug report, please look through the Android troubleshooting page first. If this doesn't solve the problem, proceed to reporting an Android bug.

How Unity Android Differs from Desktop Unity

Strongly Typed JavaScript

Dynamic typing in JavaScript is always turned off in Unity Android. This is the same as adding #pragma strict to your scripts, but it is done by default instead. This greatly improves performance (which is especially important on the iPhone/iPad devices). When you launch an existing Unity Project, you will receive compiler errors if you are using dynamic typing. You can easily fix them by either using static typing for the variables that are causing errors or taking advantage of type interface.

Terrain Engine

The terrain engine is not supported on Android devices yet. The terrain engine is built to work with modern PC GPUs and can't be scaled down to anything currently suitable for Android. Using custom low poly meshes and occlusion culling is the best way to create terrains on Android devices.

ETC as Recommended Texture Compression

While Unity Android does support DXT/PVRTC/ATC textures, Unity will decompress the textures into RGB(A) format at runtime if those compression methods are not supported by the actual hardware. This could have an impact on the GPU rendering speed and it is recommended to use the ETC format instead. The ETC compression is regarded as the standard compression format on Android, and should be supported on all post 2.0 devices. ETC however does not support the alpha channel and, depending on the use case for such a texture, RGBA 16-bit might be the best trade-off between size, quality and rendering speed.

It's also possible to create separate android distribution archives (.apk) for each of the DXT/PVRTC/ATC formats, and let the Android Market filtering select the correct archive for the different devices (see Publishing Builds for Android).

Movie Playback

Movie textures are not supported on Android, but a full-screen streaming playback is provided via scripting functions. To learn about supported file formats and scripting API, consult the movie page or the Android supported media formats page.

Further Reading

Page last updated: 2011-05-31