Skip to main content
Inspiring
January 20, 2020

All of a sudden! Build for Android fails: Specified cast is not valid.

I did not change anything that I am aware of and get now.

Specified cast is not valid.
UnityEngine.Debug:LogError(Object)
OVRGradleGeneration:PatchAndroidManifest(String) (at Assets/Oculus/VR/Editor/OVRGradleGeneration.cs:348)
OVRGradleGeneration:OnPostGenerateGradleAndroidProject(String) (at Assets/Oculus/VR/Editor/OVRGradleGeneration.cs:170)
UnityEditor.EditorApplication:Internal_CallGlobalEventHandler() (at /Users/builduser/buildslave/unity/build/Editor/Mono/EditorApplication.cs:442)

I found out that OVRGradleGeneration : 296 throws an error on the 3rd element when iterating
                     foreach (XmlElement e in appNodeList)

Unity 2019.3.0f5
latest Oculus Android Package: 2.38.6
NDK, Gradle, JDK from 2019.3.0f5 installation 
android sdk: level 25
This topic has been closed for replies.

2 replies

New Participant
January 26, 2020
I had same issue and the problem was the comments which I had inside application tag from AndroidManifest.xml 
New Participant
April 27, 2020
I had the same issue and removing the commented out code worked! Thanks.