Version: 2019.4
Native (C++) plug-ins for Android
Android mobile scripting

Using Java or Kotlin source files as plug-ins

Unity supports plug-ins for Android written in Java or Kotlin. This functionality allows you to add .java or .kt files into your Unity Project and they are compiled when you build an Android Player. Previously, you had to precompile these files as an Android library.

To compile the source files as a plug-in, follow these steps:

  1. Open the Unity Editor.
  2. Select the Project to add the plug-in to.
  3. In the Projects window, select the Assets folder and create a folder for your plug-in (you can drop directly to Assets, but for real project it’s better to use subfolder).
  4. Drag and drop your source files into the folder.
  5. Select each of the files.
  6. In the inspector window, under Select platforms for plugin, verify that only Android is selected.
  7. Build your Project.

Note: You can place your source files in any folder in your Project except in special use locations such as StreamingAssets. If you place files in these locations, the Unity Editor will not display the plug-in inspector. For additional information, see AAR plug-ins and Android Libraries.

Use the AndroidJavaObject class to call methods in your plug-in. For additional information see, the “Using your Java plug-in from C# scripts with helper classes” section in JAR plug-ins.

Symlink Sources

To enable direct referencing of the Java and Kotlin files in the exported gradle project and eliminte the need to manually copy the edited Java and Kotlin files from the exported gradle project to the Unity Project, enable Symlink Sources in the Build Settings window.


  • 2018–12–08 Added Symlink Sources option.
  • 2018–11–29 Page amended
  • 2018–09–07 Page published
  • Added plug-in support in 2018.2
Native (C++) plug-ins for Android
Android mobile scripting
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961