1.谷歌官网提供的VR资源下载
网站
https://github.com/googlevr/gvr-android-sdk/此网站是国外的网站,需要翻墙。
2.因为使用VR的资源很小号内存,所以我们为了避免OOM的问题,在清单文件中添加 android:largeHeap="true",提高警报线。
清单文件代码:
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:largeHeap="true"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
3..由于低版本要用高版本的东西,在Gradle文件中添加
compile 'com.google.android.exoplayer:exoplayer:r1.5.10'
compile 'com.google.protobuf.nano:protobuf-javanano:3.0.0-alpha-7'
4.导入三个库文件common,commonwidget,videowidget
目录为gvr-android-sdk-master\libraries下的三个文件
再添加到moudle中,Ctrl+Alt+Shift+S,选择你的moudle,点击右上角加号,导入需要的三个库文件;
5.编译构造版本太低,2.0后的studio没办法导入此model.
会爆出这个异常,解决的办法是进入文件里,修改build.gradle文件
6.在布局文件中添加VR控件和进度条控件: