Yesterday we looked at how we can work with VR and went through the basic demo and understood how everything worked.
Today, we’re going to look at how we can install our game directly into the phone.
To do everything today, we need to have:
Today we’re going to:
With all that being said, let’s get started! Today we’ll be following Unity’s Android SDK setup guide
Since we’re building our VR app for Android applications, we need the required software to compile, build, and run our app on our phone.
When we’re done downloading and installing Android Studio (which will take a LONG time), we want to open the SDK Manager.
In our new project, we can find our SDK Manager under Configure.
Now we’ll get this:
Under SDK Platform, select the platform we want to support, in this, case it’s Android 4.4 for Cardboard and Android 7.0 for DayDream, however, I believe if you install the newest version that’ll work for both.
Under SDK Tools, install:
With all of this, we should now have everything we need to be able to build our game into our Android device.
The next part (and probably the part I hate the most) is installing a USB driver that allows our computer to detect our phone.
With any luck, your computer should be able to successfully recognize your phone when you plug it into your computer.
If not, then I refer you to Google this problem as there are too many possibilities of what could have gone wrong.
Now our computer can connect to our mobile device, the final thing we need to do is have our phone be in developer mode so Unity (or Android) can create the app and install it on our phone.
The instructions to enable Developer Mode varies depending on what your phone is. A quick Google search should give you what you need to enable it.
However, the most common approach these days is to:
Now under Settings, you should find Developer options.
Hopefully, with this step completed, we can finally move on to our configurations in Unity!
Now that our phone is ready, it’s time to finally build our game into Unity.
That’s it. Now in the perfect world, that’s it, we’re done. Enjoy our VR game!
Unfortunately, there are always problems that we would encounter:
The 1st and 2nd problem can be resolved easily.
The first problem is because we need to make sure that we create a minimum version of Android devices that have the software we need to run our VR application.
For the second problem, every Android app has a unique identifier that Google uses to identify the app. The error that we’re getting is that Unity is telling us that we’re using the default one and we should change it.
Now for the third and final problem. This one more interesting. Most likely your error is something like this:
Failed to compile resources with the following parameters:
-bootclasspath "C:/Users/JoshDesktop/AppData/Local/Android/android-sdk\platforms\android-24\android.jar" -d "C:\Users\JoshDesktop\git\Cardboard\Temp\StagingArea\bin\classes" -source 1.6 -target 1.6 -encoding UTF-8 "com\google\android\exoplayer\R.java" "com\google\gvr\exoplayersupport\R.java" "com\google\gvr\keyboardsupport\R.java" "com\google\gvr\permissionsupport\R.java" "com\google\vr\cardboard\R.java" "com\google\vr\keyboard\R.java" "com\Josh\Chang\R.java" "com\unity3d\unitygvr\R.java"
warning: C:\Users\JoshDesktop\AppData\Local\Android\android-sdk\platforms\android-24\android.jar(java/lang/Object.class): major version 52 is newer than 51, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: C:\Users\JoshDesktop\AppData\Local\Android\android-sdk\platforms\android-24\android.jar(java/lang/AutoCloseable.class): major version 52 is newer than 51, the highest major version supported by this compiler.
What all of this is saying is that our Java is out of date and we need to have at least Java SDK 8.52.
In my case, I previously had 8.51 installed and when I installed version 8.52, Unity didn’t pick up on the changes.
To fix this:
With all of this done, hopefully, you should be able to successfully build and run the GvrDemo on your phone + Google Cardboard if you have one.
Hopefully, this was a useful guide to getting your Android device set up to play the scene. Leave a comment if you run into problems and I’ll try to help and update this article with any new information.
On a different note, it’s truly amazing playing with VR on our own mobile device. Just playing the VR game from Unity was interesting, but words can’t describe how much more realistic and interesting it becomes until you strap your phone onto your face!
I think at this point, we have a good understanding of the basics and what is and isn’t possible with the Google Cardboard now.
Tomorrow we’re going to look and see how we can incorporate the VR SDK into our simple FPS game to see how our game fairs in VR!