Unity+to+Android+and+GearVR+Workflow

toc = __How to Export Unity Models Into Android Application (Mac OS X)__ =

In order to export Unity into Android application, there are several steps that need to be done:

__**Install Android SDK **__
 * Go to [|__https://developer.android.com/studio/index.html__] and look for SDK tool package that suits your computer. See Figure 1.
 * Note ** : Make sure you scroll down the web page and look for ** __‘Get just the command line tools’__ **

** Figure 1: How to find the correct SDK tool package for Mac OS X **
 * Download the file from Mac OS X.


 * To install the SDK tools package into your system, access the folder ‘tools’ and double click on **‘android’**. See Figure 2 for details

** Figure 2: How to install SDK tools package into your computer system **

**Note**: Make sure that at least one Android platform with API level equal to or higher than 9, Platform Tools, and USB Drivers (only for Windows) are selected and installed
 * This will bring up the Android SDK Manager window. See Figure 3.

** Figure 3: What to install from Android SDK Manager **
 * __ Install JDK __ **
 * Go to [|__http://www.oracle.com/technetwork/java/javase/downloads/index.html__] to download appropriate JDK file. See Figure 4.

** Figure 4: Download and Installing JDK **

** __Android Device Configuration__ **

 * Turn your android phone from Standard Mode to Developer Mode by:
 * ** Access ** **Settings → System → About Device → Build Number (Tap 7 times)**. This will change your phone from Standard Mode to Developer Mode


 * Turn on USB Debugging in your android phone by (ONLY work when you are in Developer Mode)
 * ** Access Settings → System → Developer Options → Enable ‘USB debugging’ **

** __Configuring Settings in Unity to Make It Compatible to Android System__ **

 * Check that the SDK and JDK a properly loaded into Unity by clicking **‘Unity’ → ‘Preferences’ → ‘External Tools’**. See Figure 5.

** Figure 5: Check SDK and JDK is properly loaded to Unity **

**Note**:
 * To load SDK into Unity, locate your ** ‘android-sdk-macosx’ ** folder and choose that folder
 * To load JDK into Unity, access ** ‘/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/’ ** from your computer (exact jdk version will change over time)


 * Switch Unity platform to Android platform by going to **‘** ** File’ → ‘Build Settings’ → ‘Android’ → ‘Switch Platforms’ ** **.** See Figure 6.
 * Note: ** Click ** ‘Add Open Scene’ ** to add your scene into the build

** Figure 6: Switching Unity platform to Android platform **
 * Access Editor Setting. Click ** ‘Edit’ → ‘Project Settings’ → ‘Editor’ ** . Change Device to **‘Any Android Device’**. See Figure 7.

** Figure 7: Configure Editor Settings **
 * Configure Player Settings. Player Settings can be accessed from ** ‘File’ → ‘Build Settings’ → ‘Player Settings’ ** . See Figure 8.

** Figure 8: How to access Player Settings **
 * Input ** ‘Company Name’, ‘Product name’, and ‘Bundle Identifier’ ** . __**IMPORTANT**:__In **‘Bundle Identifier’**, the name MUST be in this format: ** com.(Company Name).(Product Name). ** Company and product name must be identical with the **‘Bundle Identifier’.** See Figure 9.

** Figure 9: Configuring Player Settings **

** __Exporting Unity to Android Platform__ **

 * To export Unity model into Android platform, click ** ‘File’ → ‘Build Settings’ → ‘Android’ → ‘Build & Run’ **

** __If building for GearVR, you need to also make sure you put your oculus signature file in your project:__ **
> YourProjectName --- > assets --> Plugins ---> android ---> assets.
 * Open terminal on your Mac, navigate to your android sdk folder-> platform-tools, then type ./adb devices, you will get a devices id.
 * Go to : https://developer.oculus.com/osig/ and download the signature to


 * Note: **
 * Make sure that Prefabs for ‘Cross Platform Input’ is loaded into the scene. These prefabs can be accessed from standard assets.
 * Make sure that USB is connected to the Android Device

= __How to Export Unity Models Into Android Application (Windows)__ =

In order to export Unity into Android application, there are several steps that need to be done:

** __Install Android SDK__ **
**Note**: Make sure you scroll down the webpage and look for ** __‘Get just the command line tools’__ **
 * Go to [|__https://developer.android.com/studio/index.html__] and look for SDK tool package that suits your computer. See Figure 1.

** Figure 1: How to find the correct SDK tool package for Windows **
 * Download the .exe for Windows

**Note**: Take note of the **‘Destination Folder’** as we will need this information in order to map it to Unity.
 * To install the SDK tools package into your system, double-click the .exe file that you just downloaded. Follow the instructions to install Android SDK tools. Choose ‘Install for anyone using this computer’. See Figure 2.

** Figure 2: How to install SDK tools package into your computer system ** **Note**: Make sure that at least one Android platform with API level equal to or higher than 9, Platform Tools, and Google USB Drivers are selected and installed
 * After installation, it will bring up the Android SDK Manager window. See Figure 3.

** Figure 3: What to install from Android SDK Manager **

__Download Suitable Driver for your Device__
** Figure 4: How to find suitable OEM drivers for your device **
 * Usually **‘Google USB Driver’** only works for Google devices such as Google Nexus. If your phone device is not Google Nexus, go to [|__https://developer.android.com/studio/run/oem-usb.html__] and find your OEM drivers. See Figure 4.
 * Click the designated website (based on the type of your Android device) and install the appropriate USB driver.

**Note**: This step is very important as without appropriate driver, your Unity model will not run on your Android device.

** __Install JDK__ **

 * Go to [|__http://www.oracle.com/technetwork/java/javase/downloads/index.html__] to download appropriate JDK file. See Figure 5.

** Figure 5: Download and Installing JDK **

** __Android Device Configuration__ **

 * Turn your android phone from Standard Mode to Developer Mode by:
 * Access **Settings → System → About Device → Build Number (Tap 7 times)**. This will change your phone from Standard Mode to Developer Mode


 * Turn on USB Debugging in your android phone by (ONLY work when you are in Developer Mode)
 * Access **Settings → System → Developer Options → Enable ‘USB debugging’**

** __Configuring Settings in Unity to Make It Compatible to Android System__ **

 * Check that the SDK and JDK are properly loaded into Unity by clicking **‘Edit’ → ‘Preferences’ → ‘External Tools’**. See Figure 6.

** Figure 6: Check SDK and JDK is properly loaded to Unity ** **Note**: Click **‘Add Open Scene’** to add your scene into the build
 * Switch Unity platform to Android platform by going to **‘File’ → ‘Build Settings’ → ‘Android’ → ‘Switch Platforms’**. See Figure 7.

** Figure 7: Switching Unity platform to Android platform **
 * Access Editor Setting. Click **‘Edit’ → ‘Project Settings’ → ‘Editor’**. Change Device to **‘Any Android Device’**. See Figure 8.

** Figure 8: Configure Editor Settings **
 * Configure Player Settings. Player Settings can be accessed from **‘File’ → ‘Build Settings’ → ‘Player Settings’**. See Figure 9.

** Figure 9: How to access Player Settings **
 * Input **‘Company Name’, ‘Product name’, and ‘Bundle Identifier’**. ** __IMPORTANT:__ ** In **‘Bundle Identifier’**, the name MUST be in this format: com.(Company Name).(Product Name). Company and product name must be identical with the **‘Bundle Identifier’**. See Figure 10.

** Figure 10: Configuring Player Settings **

** __Exporting Unity to Android Platform__ **

 * To export Unity model into Android platform, click **‘File’ → ‘Build Settings’ → ‘Android’ → ‘Build’**

**Note**:
 * Make sure that Prefabs for ‘Cross Platform Input’ is loaded into the scene. These prefabs can be accessed from standard assets.
 * Make sure that USB is connected to the Android Device