Legacy Documentation: Version 2018.2 (Go to current version)
Building and using plug-ins for Android
JAR plug-ins
Other Versions

AAR plug-ins and Android Libraries

AAR plug-ins

Android Archive (AAR) plug-insA set of code created outside of Unity that creates functionality in Unity. There are two kinds of plug-ins you can use in Unity: Managed plug-ins (managed .NET assemblies created with tools like Visual Studio) and Native plug-ins (platform-specific native code libraries). More info
See in Glossary
are bundles that include compiled Java and native (C/C++) code, resources, and an Android Manifest. The .aar file itself is a zip archive which contains all of the AssetsAny media or data that can be used in your game or Project. An asset may come from a file created outside of Unity, such as a 3D model, an audio file or an image. You can also create some asset types in Unity, such as an Animator Controller, an Audio Mixer or a Render Texture. More info
See in Glossary
. For more details, see Android Developer documentation on creating an Android Library.

To add an AAR plug-in to your project, copy the .aar file into any of your project folders, then select it in Unity to open the Import Settings in the InspectorA Unity window that displays information about the currently selected GameObject, Asset or Project Settings, alowing you to inspect and edit the values. More info
See in Glossary
window. Tick the Android checkbox to mark this .aar file as compatible with Unity:

ARR plug-in import settings as displayed in the Inspector window
ARR plug-in import settings as displayed in the Inspector window

AAR is the recommended plug-in format for Unity Android applications.

Android Library Projects

Android Library projects are similar to AAR plug-ins: they contain native and Java code, resources, and an Android Manifest. However, an Android Library is not a single archive file, but a directory with a special structure which contains all of the Assets. For more details, see Android Developer documentation on creating an Android Library.

Import pre-compiled Android library projects into the Assets/Plugins/Android folder. Pre-compiled means that all .java files must have been compiled into .jar files and placed in either the bin/ or the libs/ folder of the Android Studio project before being imported into Unity. From these folders, AndroidManifest.xml gets automatically merged with the main manifest file when the project is built.

Unity treats any subfolder of Assets/Plugins/Android as a potential Android Library, and disables Asset importing from within these subfolders. The subfolder is recognized as an Android Library if it contains the AndroidManifest.xml file, and the project.properties file contains the string android.library=true.

See Android Developer documentation on the Library module for more details.

Providing additional Android Assets and resources

If you need to add Assets to your Unity application that should be copied unchanged into the output package, import them into the Assets/Plugins/Android/assets directory. They appear in the assets/ directory of your APKThe Android Package format output by Unity. An APK is automatically deployed to your device when you select File > Build & Run. More info
See in Glossary
, and are accessed by using the getAssets() Android API from your Java code.



Did you find this page useful? Please give it a rating:

Building and using plug-ins for Android
JAR plug-ins