Explorations with Cardboard! (and Android Studio)

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.

 Screen Shot 2014-06-30 at 12.14.28 AM

 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.

Screen Shot 2014-06-30 at 12.20.50 AM

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.

Screen Shot 2014-06-30 at 12.24.51 AM


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.

Screen Shot 2014-06-30 at 12.27.31 AM


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.

Screen Shot 2014-06-30 at 12.30.32 AM


Yep, happy build.

Screen Shot 2014-06-30 at 12.40.13 AM

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!

2 thoughts on “Explorations with Cardboard! (and Android Studio)

  1. Hey Alexander,

    I caught wind of this post after trying to figure out how to the same thing the other day, when my headset came in. However, I’m having lots of trouble- chiefly, because I’m not using GitHub at all. That’s something I’d like to get into, but I’m not quite sure what the setup for that needs to be! (I was taught in class, but by a professor that doesn’t explain anything, so the idea never stuck) Where would you recommend getting started with setting up Git/Gradle in order to be able to pull the Cardboard demo repo and get started?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s