岡竜之介のブログ

岡竜之介のブログです。

UnityのGoogleCardboard用デモをNexus5で動かすまで I made a demo for Google Cardboard work on my Nexus5

f:id:agajo:20161116100918p:plain


UnityのGoogleCardboard用デモをNexus5で動かすまでだけで3日くらいかかったんですよ。
It took about 3 days to make a demo work on my Nexus5. The demo is for Google Cardboard on Unity.


自分が雑魚過ぎて情けないですね。
My ability is low and I am miserable.



How will I see this message hundreds more time before I can see the cube floating in the air on this smartphone?



I have no idea.... What's going on with GoogleUnityActivity...?


ちなみにこの記事は今これを書いてる2016年11月15日前後にしか役に立たないはずです。
By the way, this article should be useful only around November 15, 2016 writing this now.



数ヶ月もすれば、公式アップデートにより解決することでしょう。
A few months later, it will be resolved by official update.

症状 What's happening

Googleの公式ドキュメントに書いてあることを淡々と進めただけなのに、
I just made progress on what I saw in the official Google document,


Android実機(Nexus 5)に向けてBuildすると、直ちにクラッシュする。
but after building for the Android real machine (Nexus 5), it immediately crashes.



結論 Solution


いきなり結論です。こういう「情報を伝える」タイプの記事は結論が先にある方がいいんです。
It is a sudden conclusion. In an article of the type that conveys information like this, it is better to have a conclusion first.

Daydream technical preview を使わない Do Not Use Daydream technical preview

Unity+Google Cardboard開発メモ(Daydream対応) - フレームシンセシス(Japanese website)

こちらのページに「ただし、現時点ではDaydream非対応端末でのパフォーマンスに問題があるようです。」とあるように、
As mentioned in this page "However, it seems that there is a problem with the performance on the daydream incompatible terminal at the moment"


Daydream technical preview版のUnityを使ってDaydream非対応端末向けに開発をすると、失敗するようです。
It seems to fail if you develop for daydream incompatible terminals using Daydream technical preview version of Unity.


通常版を使う方法も併記してあるので、そちらの方法で試した所、うまくいきました。
The method to use the regular version is also included, and it worked out well.

Unityは普通に再インストールしただけで大丈夫でした。
It was okay just to reinstall Unity normally.


試したこと What I tried

Virtual Reality Supported を cardboardだけにする Choose Only "cardboard" in "Virtual Reality Supported"

Build時のPlayer Settingsの中にある「Virtual Reality Supported」という項目です。
It is the item "Virtual Reality Supported" in Player Settings when it is builded.


Daydream technical preview版を使っていると設定できます。
You can choose this if you use Daydream technical preview.


が、ダメ。OculusにしようがDaydreamにしようがcardboardにしようが解決せず。
However, it didn't work. Choosing Oculus or Daydream didn't work, neither.

SDKのバージョンを変えてみる Change the version of the SDK

[Unity] アプリをビルドしてandroid実機上でテストする | Unity 3DCG

こちらのページに書いてあった方法…をやったつもりですが、もはや効いたのか効いてないのかよくわからなくなってしまった。
I intended to do the method that was written on this page ... but I do not know well whether it is effective or not.



最終的にはこうなってる。
It's finally like this.

f:id:agajo:20161116131920p:plain


一度Android Studio用のプロジェクトファイルを書出し、Android Studio経由でビルドする Once you write the project file for Android Studio and build it via Android Studio

Unity CardBoard SDKを使った簡単なVRアプリ開発 in Android | Tech Blog - リクルート住まいカンパニー

こちらのページに書いてあった方法ですが、効かず。
Although it is the method written on this page, it does not work.

原因の掘り下げ Drill down on causes


Android Studio とかいうのを使ってエラーメッセージを確認した所、
I confirmed the error message using Android Studio.

java.lang.ClassNotFoundException: Didn't find class "com.google.unity.GoogleUnityActivity"

が原因だということがわかりました。
It's the cause.


このActivityとかいう奴が、僕が動かそうとしてるDemoだとGoogleUnityActivityなんですが
The demo I want to make move uses "GoogleUnityActivity",


Daydream対応版のUnityを使うとUnityPlayerActivityになっていて、
but Unity of Daydream version uses "UnityPlayerActivity".

「GoogleUnityActivityなんて見つかりませんよ!」というエラーが出る。
Then, it says "I can't find GoogleUnityActivity!!!!"


ということっぽい。ということまでわかりましたとさ!!!!
This is what I found!! That's all!!!


そのうちこのDemoの方もUnityPlayerActivityに対応して、この記事は価値を失っていくことでしょう。(2016/11/15)
In the meantime, this Demo will correspond to the UnityPlayerActivity. This article will lose value. November 15, 2016