- Home /
GoogleVR - Cardboard + Android build error
Using the GoogleVR SDK, I have created a very basic scene in Unity, involving a 'recticle' that changes the color of a cube when the user hovers over it. This works completely as expected in play mode, however, when I build it to android and run it on my device (Motorola G4 - Android 7.0) I observed some strange behavior. Usually, the recticle would expand when it is over the cube but, on my device, this doesn't happen and instead it works when the recticle is offset to the left of the cube. Why is this happening?
The only thing that I have changed that could've possibly caused this is deleting the /Assets/Plugins/Android folder as I had to do this to enable to project to build because Unity was "unable to convert classes into dex format", meaning that multiple classes with the same name existed. (I'm not sure why and I couldn't find any other matching classes, but deleting the folder seemed to fix the issue)
Thanks in advance, - Callum
Answer by Liinnkk · May 05, 2017 at 01:17 PM
Are you using Unity 5.6? If yes, your problem can be the native compatibility with Google Cardboard implemented in Unity 5.6.
If you downloaded Cardboard SDK from https://developers.google.com/vr/unity/ and you're using Unity 5.6 version, then this "strange behavior" you talk may be just some conflicts between the Unity's Cardboard Native Support and the Google's External SDK.
This happens because when you play your game in Editor Mode, you're playing in PC plataform, which ISN'T affected by Unity's Cardboard Native Support — here only Google's External SDK is working. And when you build your app for Android and play the game on your Smartphone, you're playing on Android's plataform, which IS affected by native support and by Google's External SDK at the same time, what could generate some those strange behaviours when you port the game for android.
So here are the facts:
Since 5.6, you MUST enable Virtual Reality Support and select Cardboard or Daydream.
And if you want to emulate VR in Editor or use another feature exclusive to Google's External SDK (see https://developers.google.com/vr/unity/), then you should add Cardboard SDK as well.
Since my case is similar to yours, but I'm not facing any problem, I'll give you some idea of my hierarchy (Android/Cardboard). With Virtual Reality Supported enabled and Cardboard listed in the Player Settings, I have the following Gvr objects in my scene:
GvrViewerMain: with the 'GvrViewer' script.
GvrReticlePointer: as a child of my 'Main Camera , with the 'GvrReticlePointer' script.
EventSystem: with GvrPointerManager and GvrPointerInputModule scripts. Remember to Disable the Standalone Input Module here.
@Liinnkk Ok, thanks, that makes sense but how would I go about disabling/removing one of them? I've tried deleting the external SD$$anonymous$$ but that doesn't work seeing as the project uses prefabs and scripts etc. that are included in it. I also tried disabling the 'Virtual Reality Supported" button under the Player Settings because I thought this might have something to do with the "Native Support" that you mentioned, this got rid of the weird plugin errors I had before and the game built without any errors but when I installed it on my smartphone It failed, saying the file was corrupt. What would be the best way for me to use only one of the approaches?
@callumlk00 Hmm... actually, it depends on how you've developed your project so far. But I have done some research and I found that the Google SD$$anonymous$$ was updated and some drastic changes were made. For my understanding now, you must check the Support Virtual Reality under the Player Settings and select Google Cardboard or Daydream. So now Native Support is not optional as I told you before — my bad. Actually, using Unity's Cardboard Native Support and Google SD$$anonymous$$ (which is now implemented to work aside native support) is a good approach, specially because Google SD$$anonymous$$ let you emulate Virtual Reality through mouse and keyboard, allowing you to test your VR game in Editor's Play $$anonymous$$ode.
So here are the facts:
You $$anonymous$$UST enable Virtual Reality Support and select Cardboard or Daydream.
If you want to emulate VR in Editor, you should add Cardboard SD$$anonymous$$ as well.
Since my case is similar to yours, but I'm not facing any problem, I'll give you some idea of my hierarchy (Android/Cardboard). With Virtual Reality Supported enabled and Cardboard listed in the Player Settings, I have the following Gvr objects in my scene:
GvrViewer$$anonymous$$ain: with the 'GvrViewer' script.
GvrReticlePointer: as a child of my '$$anonymous$$ain Camera , with the 'GvrReticlePointer' script.
EventSystem: with GvrPointer$$anonymous$$anager and GvrPointerInput$$anonymous$$odule scripts. Remember to Disable the Standalone Input $$anonymous$$odule here.
I'll update my answer as soon as we discover what's causing your problem.
Okay... $$anonymous$$anaged to sort it out: I created a new blank project to recreate the hierarchy you described and in doing so I installed the latest version of the Google VR SD$$anonymous$$.
I loaded one of the demo scenes and built it and then ran it on my android device. This seemed to fix the issue and now everything works just fine.
Thanks for the help!