So it turns out that getting the Cardboard Sample to compile is a lot easier than I thought. Who knew that things you fetch from github tend to work on the first try? (or rather, second…)
I became really interested in Google’s new Cardboard project after attending Google I/O this past week. After all, having no experience with computer imaging or rendering and also having no experience with virtual reality makes me the best target candidate for this project, right?
The project developers state that Cardboard is intended to bring virtual reality to the masses. The goggles are made out of their namesake material, cardboard, with the most complex parts being a set of lenses (used to focus the viewer’s eyesight), one’s smartphone, and a set of magnets used for input to the smartphone. This greatly enhances the approachability of the device compared to the futuristic creations by OculusVR and similar competitors in the virtual reality space. I hope the devices gain popularity among developers, especially among curious individuals who haven’t ever developed for this platform (like me!). I can’t wait to download some amazing applications.
Enough speculation. Onto the run!
I haven’t messed with Android for a few months now, and I was quite surprised to notice that Google has released their Android Studio, so I decided to give it a whirl. This combined with their new build system, Gradle, that the sample project uses as a dependency manager caused me to have a slight hiccup that I will document here.
Upon downloading Android Studio, and opening it for the first time, I was very surprised to find that Android Studio has Github Integration! Thus, importing the project was a breeze, as I simply put in my github credentials, selected the repository I wanted to pull from, and voilà, the repository was cloned.
After cloning my project, I unfortunately fell into the trap of using the old Eclipse Android Developer Tools method of running the project, with the Run command. However, a more astute individual would have realized that this is a Gradle project! Since it is a Gradle project, we must use the Gradle method of running it. There are two choices, using the Gradle sidebar (red arrows), or the Gradle Console (blue arrow). Since I don’t know the console commands, I’ll use the sidebar.
So, after clicking the Gradle sidebar, I noticed that there are a lot of build commands. I chose the ‘install debug’ one, which builds the android project, signs it with a debug key, and loads it onto my development device.
Oh no! Looks like I got an error. For some reason, the build does not like using the ‘L’ support library, as shown in this helpful StackOverflow post. Guess I’ll have to edit the AndroidManifest.xml.
Per the solutions in the StackOverflow post, I changed compile ‘com.android.support:support-v4:+’ to ‘compile ‘com.android.support:support-v4:19.1.0’. I think this problem only occurs if my android build tool is not updated to the version that supports ‘L’, since the older build tool doesn’t have support for the codename. Haven’t tested it though. In any case, this seems to resolve the build problem.
Yep, happy build.
Since I’m debugging on a HTC One with USB Debugging enabled, I noticed that the app is now on my phone. Mission Success!
Hooray for Cardboard!