VR Issues with CommandInvokationFailure, exit code 1

CommandInvokationFailure: Unable to
merge android manifests. See the
Console for more details. C:/Program
Files/Java/jdk1.8.0_144\bin\java.exe
-Xmx2048M -Dcom.android.sdkmanager.toolsdir=“C:/Users/owlsntea/AppData/Local/Android/sdk1 ools”
-Dfile.encoding=UTF8 -jar “C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\sdktools.jar”

stderr[

] stdout[ Warning:
[Temp\StagingArea\AndroidManifest-main.xml:12,
C:\Users\owlsntea\Desktop\vrtests\New
Unity Project
1\Temp\StagingArea\android-libraries\gvr-keyboard\AndroidManifest.xml:2]
Main manifest has android:targetSdkVersion=‘23’> but
library uses targetSdkVersion=‘24’
Warning:
[Temp\StagingArea\AndroidManifest-main.xml:12,
C:\Users\owlsntea\Desktop\vrtests\New
Unity Project
1\Temp\StagingArea\android-libraries\gvr-keyboardsupport-release\AndroidManifest.xml:3]
Main manifest has android:targetSdkVersion=‘23’> but
library uses targetSdkVersion=‘24’
Warning:
[Temp\StagingArea\AndroidManifest-main.xml:12,
C:\Users\owlsntea\Desktop\vrtests\New
Unity Project
1\Temp\StagingArea\android-libraries\gvr-permissionsupport-release\AndroidManifest.xml:3]
Main manifest has android:targetSdkVersion=‘23’> but
library uses targetSdkVersion=‘24’ ]
exit code: 1
UnityEditor.Android.Command.Run
(System.Diagnostics.ProcessStartInfo
psi,
UnityEditor.Android.WaitingForProcessToExit
waitingForProcessToExit, System.String
errorMsg)
UnityEditor.Android.AndroidSDKTools.RunCommandInternal
(System.String javaExe, System.String
sdkToolsDir, System.String
sdkToolCommand, Int32 memoryMB,
System.String workingdir,
UnityEditor.Android.WaitingForProcessToExit
waitingForProcessToExit, System.String
errorMsg)
UnityEditor.Android.AndroidSDKTools.RunCommandSafe
(System.String javaExe, System.String
sdkToolsDir, System.String
sdkToolCommand, Int32 memoryMB,
System.String workingdir,
UnityEditor.Android.WaitingForProcessToExit
waitingForProcessToExit, System.String
errorMsg) UnityEditor.HostView:OnGUI()

OK!

My goal was simple. Add a small scene, add a VR camera, build for Android, test in Cardboard. No animation, particles, code, etc.

So here is Unity 5.6.0f3. I drop in a few assets, start a build, test on phone, everything’s swell! No camera movement, but I haven’t added that yet…

But then!

I import GoogleVRForUnity_1.70.0 into the project. Before I even drop the VR camera into the scene, I tempt fate and immediately hit build, yielding three errors. The first two errors tell me I need to specify in my Build that I’m using VR and Cardboard. The third error is the on listed above.

Clear the console, go into personal settings, check VR Supported, enter in my VR Cardboard selection, and attempted to Build Again. The first two errors were gone, but the CommandInvokationFailure was back!

The internet wasn’t much help. Plenty of the other errors similar to this exist, and their advice was to make sure I was using various odds and ends- 25.2 tools, NDK10, I followed all of those to the best of my ability… but nothing has worked.

I even tried changing my Java version.

I tried to analyze the error as best I could- I noticed it was upset about my target SDK version, so I opened up my SDK manager, and made sure that Android 6 (23) was the only thing selected. I went into Unity, and checked my external settings.

I have tried using Unity 5.5, 5.6, and the newest 2017, and in each one, I tried multiple combinations of the SDKs.

I have even tried going into C:\Users\owlsntea\Desktop\vrtests\New Unity Project 1\Temp\StagingArea\android-libraries\gvr-permissionsupport-release\AndroidManifest.xml. I changed the 19 and 24 to 23 and 23. I changed it also for the keyboard, and keyboard support, and it broke even harder.

I just want to find the right combo.

If you’ve done it, please don’t try to fix my problem. Just tell me which Unity, Java, SDK and NDK I need.
This is my third full 12-hour or more day of trying to fix it. I’ve read hundreds of articles. I even read the manual and release notes for each version of Unity AND Android.

At this point, I feel like it just hates me. Three full days wasted because I always feel like asking for help is just a convoluted, snarkier version of using google search. So yeah, I RTFMs and sacrificed three days of my life. Please somebody hold my pencil in my hand and write my name for me! Hugs and kisses, OwlTeaGames!

According to the error, your project (the “main manifest”) is configured to use targetSdkVersion 23, but a library (plugin) declares it must use targetSdkVersion 24, which causes a conflict and so the manifests cannot be all merged into a single one to form the APK.

I don’t remember exactly how it works in Unity 5.5, 5.6 and 2017 (since the behavior changed at some point), but the targetSdkVersion was determined in different ways:

  1. If you have a “main manifest”, e.g: Assets/Plugins/Android/AndroidManifest.xml, the version will be picked up from there.
  2. If there’s no “main manifest”, Unity will pick up the latest version from the Android SDK you have available.
  3. At some Unity version, they added the option to manually specify this value directly in the Player settings.

I suggest you to try and specify targetSdkVersion to be 24 (either via the Unity UI or from the manifest file) and see if that works.

Modifying files under Temp/StagingArea won’t help, as this folder is being regenerated with every new build that you make.

NOTE: In case you’re not able to solve this issue yourself, please be advised that i offer a professional service for consulting on these exact type of cases. Feel free to contact me and i will assist you.