LoginSignup
2
3

More than 5 years have passed since last update.

UnityでGear VRのビルドができなくなった時の対処法

Last updated at Posted at 2017-09-11

UnityでGear VR用apkのビルドができなくなっていた。Unable to merge android manifest Errorとかいうエラーが出る。Build SystemをInternalからGradleに変えてみたりもしたけど、エラーメッセージがちょっと変わるだけで状況は変わらず。

どうやらGear VR用のプラグイン(OVRPlugin)の中で定義されているAndroidManifest.xmlとUnityが生成するAndroidManifest.xmlの値が競合しているようです。具体的には、Gear VR用プラグインでは<application android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">を指定している一方でUnityは<application android:theme="@style/UnityThemeSelector">を指定しています。そこで、Unity側の設定で強制的にandroid:themeの値を上書きするようにしてみたら症状が改善してビルドできるようになりました。

修正した箇所は一行のみで、Unityのインストールディレクトリ以下にあるEditor/Data/PlaybackEngines/AndroidPlayer/Apk/AndroidManifest.xmlのファイルの<application>要素にtools:replace="theme"という属性を追加しました。

UnityInstalledDirectory/Editor/Data/PlaybackEngines/AndroidPlayer/Apk/AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.unity3d.player"
    xmlns:tools="http://schemas.android.com/tools"
    android:installLocation="preferExternal"
    android:versionCode="1"
    android:versionName="1.0">
    <supports-screens
        android:smallScreens="true"
        android:normalScreens="true"
        android:largeScreens="true"
        android:xlargeScreens="true"
        android:anyDensity="true"/>

    <application
        tools:replace="theme"
        android:theme="@style/UnityThemeSelector"
        android:icon="@drawable/app_icon"
        android:label="@string/app_name">
        <activity android:name="com.unity3d.player.UnityPlayerActivity"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
        </activity>
    </application>
</manifest>

Windowsの場合、UnityのインストールディレクトリはデフォルトでC:\Program Files\Unityです。この中のファイルには管理者権限がないと書き込みできませんので注意してください。

2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3