Unity3d Android Plugin



  1. Unity3d Android Plugin Tutorial
  2. Unity3d Android Plugin
  3. Unity Plugins

I’ve created a number of Android / Java plugins for Unity using Android Studio so thought I’d document the process.

Please let me know if there are better ways of doing any this 🙂

Update: Download Code for this

Assumptions:

Get the Bluetooth Android Plugin package from Belal Badr and speed up your game development process. Find this & other Network options on the Unity Asset Store. Android Ultimate Plugin This content is hosted by a third party provider that does not allow video views without acceptance of Targeting Cookies. Please set your cookie preferences for Targeting Cookies to yes if you wish to view videos from these providers.

  • I’m assuming that you already have Unity3D installed, if not, get it from here (Choose the most up to date version): Unity Downloads
  • I’m assuming you already have Android Studio and the relevant SDK’s installed? If not you might want to start here and here.
  • I’m assuming you have a real Android device attached via USB or you are using the emulator and are used to building Unity Projects to your device. If not, you probably want to start here.

Fire up Android Studio and Create a new project…

  • Open Android Studio a choose File -> New -> New Project

An Android Plugin for Unity3d that will help you access features on Android devices with in unity3d. This plugin will speeds up your work and saves a lot of time compare on creating your own plugin which requires learning, researching, coding and testing on how to make things work. This short article is a guide to creating a plugin to access the Android API from Unity3d.This is aimed at intermediate developers. You should be comfortable using the command line.

Plugin

Give your project a name and choose a location to save it. If you need C++ support, check that checkbox :-)….

Unity 3d plugin

(I’ve called my project “TextureHelper” but you can call yours whatever you wish. I’ll hopefully be adding some more parts to the tutorial later that show how to update Unity Textures from Java/Android. watch this space).

I normally use Unity on GearVR so I can safely choose API 22 as my minimum SDK – change this if you need to but remember what you set as you’ll need to set the same in Unity in Part 2 ….

We need to create a plugin without any activities…

This is what you should see once you’ve hit the finish button and Android Studio has created the project…

Locate the “build.gradle” file under “Gradle Scripts”. The first thing we need to do is change

apply plugin: ‘com.android.application’

Mac picture editor

…to…

apply plugin: ‘com.android.library’

This will ensure that Android Studio creates a .arr Android Archive file rather than a full Android application…

If you try to sync gradle at this point it complains….

This is easily fixed by removing the applicationId line from the defaultConfig section…. like so…

Now right click on your Java Namespace and create a new Java Class, we’re just going to create the traditional hello world… How to connect samsung kies mobile to pc wirelessly.

Name your class….

Now add a simple static method with a String return type….

Next, open up the styles.xml file in res/values and comment out the whole AppTheme section (or delete it). It’s not needed in Android Libraries (and it can cause issue, which took me a while to figure out using the Android Device Monitor and looking through logfiles. so best to remove that potential issue now).

Then open the AndroidManifest.xml file under app/manifests….

Unity3d Android Plugin Tutorial

Delete the unneeded android:icon, android:roundIcon and android:theme items….

Save those files. then hit Build > Make Project

In Windows Explorer navigate to: app/build/outputs/arr and you should find your android archive that you can drop into Unity.

You can rename this file of course, or you can get gradle to automatically rename it for you (more on that later).

Unity3d Android Plugin

Unity3d Android Plugin

Unity Plugins

In Part Two, I’ll show how to add the plugin into Unity3D and use it 🙂