Build a Cardboard Demo – Android
Prerequisite: Set up your environment for Android development.
STEP 1 – Download Google Cardboard SDK (Google search: google cardboard sdk unity github)
- Go to: https://github.com/googlesamples/cardboard-unity
- Download the Cardboard SDK as a ZIP – see below:
Make sure to EXTRACT the zip file!
STEP 2 – LAUNCH UNITY and input the paths of your Android SDK and JDK (Java SE Development Kit) so Unity can find these kits easily.
Go to: Edit > Preferences > External Tools > Android
The input fields for SDK and JDK below:
STEP 3 – Import the Cardboard SDK for Unity as a custom package.
The “CardboardSDKForUnity” package is located within the “cardboard-unity-master” folder.
Within the cardboard-unity-master folder, select CardboardSDKForUnity package:
Next, import “CardboardDemoForUnity” as a custom package:
STEP 4 – Configure the BUILD SETTINGS in Unity:
Go to: File > Build Settings (CTL + SHIFT + B)
Switch platform to “Android” – Click on “Android”
Click on “Player Settings” in the Build Settings panel.
In Player Settings, go to: “Other Settings.” Input your own unique identifier under “Bundle Identifier”
Example: “game.TestProjectAndroid”
STEP 6 – Copy the TestProjectAndroid.apk from your Unity project to your phone’s storage. Note: Your phone must be connected to your computer via USB cable.
Note: If you don’t see your phone on your computer, check to see if you have installed the USB Driver for Windows.
Use a file manager, such as Astro (which you can download for free from the Play Store), to locate the TestProjectAndroid.apk on your phone. See image below:
Click on the “TestProjectAndroid” apk on your phone. A panel will pop up, prompting you to use the “Package installer” to install the apk. Look for the green Android logo-bot!
Wait for the app to install. Once completed, your TestProjectAndroid apk will appear on the phone.
STEP 7 – Go back to Unity and load the Demo Scene into the scene view.
Go to: Assets > Cardboard > DemoScene
Click on “DemoScene” with the Unity icon. See image below:
STEP 8: Go back to Build Settings and do another build of the same TestProjectAndroid apk, but now the Cardboard DemoScene has been loaded.
Go to: File > Build Settings
Click “Build”. It will prompt you to save the apk again.
Go through the SAME INSTALLATION PROCESS:
- Save the TestProjectAndroid apk to the “Build” folder in the Unity project
- Copy and REPLACE the TestProjectAndroid apk to your phone’s storage
- Reinstall the TestProjectAndroid apk on your phone (faster process since the permissions have already been set)
Click on the TestProjectAndroid icon on your phone again, but you should see the Demo Scene!
Quick Start:
- Download Cardboard SDK – https://github.com/googlesamples/cardboard-unity
- Launch Unity and input paths of Android SDK and JDK in external preferences
- In Unity, import Cardboard SDK for Unity as custom package
- Configure BUILD SETTINGS in Unity
- Create new folder in your Unity project, call it “Build”
- Copy TestProjectAndroid.apk from Unity project to phone’s storage
- Go back to Unity and load the Demo Scene into the scene view
- Go back to Build Settings (in Unity), do another build of TestProjectAndroid apk
- Insert phone into Cardboard and voila!