Sceneform is a magnificent library which allows an unparalleled high abstraction level entry to Augmented Reality. I have several AR projects in the works using Sceneform, one example is an AR Map to help attendees with the orientation in our conference venue, it augments large signs marking the classrooms. See my further blog posts about it: part 1 and part 2.
Recently I started another Augmented Reality project using newest androidx libraries instead of old AppCompat ones and also using newest 1.16+ Sceneform SDK and surprisingly I hit some weird runtime crashes. First I got side tracked, because I started to use androidx.preference:preference:1.1.1 to eliminate plumbing code with my Settings view. As a side effect Android Studio suggests to replace <fragment> element of the ARFragment’s layout with a <androidx.fragment.app.FragmentContainerView>. That’s a trap though and don’t fall for it: it’ll lead to a NullPointerException:
This derailed me for a while but then I tried to undo changes I made one-by-one. And when that didn’t help I went back to other projects’ source codes which knowingly worked in the past (like the DevFest AR Map is actually released in the App Store). That’s when I realized I was dealing with something bigger, because every project now produced the same Exception chain:
Sometimes the Binary XML file line number is #23 instead of #22. We also see something about com.google.android.filament.gltfio.Gltfio which have not yielded any Google search results whatsoever. I went to the Sceneform SDK’s GitHub page but that is in an archived state now, therefore I could not file a new issue and I also could not comment on any existing issues. There were a few issues with similar call stacks: issue #4 and issue #188. The first suggested OpenGL ES version problem and I could rule that out since I have v3.1. The sample code checked that BTW, so I’d get an alert if it was a problem, although the check was in the AR Fragment’s code and that was crashing during the inflate. The second issue suggested 1.8 Java version change in the gradle compileOptions, but I had that already as well. As I mentioned I could not comment to the issues about my problems, or even signal a thumbs up - EXTREMELY frustrating. I filed an issue with the Sceneform Intro code lab repository but I haven’t heard back anything for several weeks. But even the Sceneform SDK has more than 560 open issues. That’s alarming and sad.
The last thing I suspected was that the Sceneform v1.16 SDK would have any breaking change compared to v1.15 or earlier, given that we were talking about minor version bumps. I accidentally glanced at the main README of the Sceneform SDK github repository and some instructions caught my eyes I haven’t seen before: you are supposed to copy two directories of the SDK and make them part of your project. Say what? This approach is concerning, because Sceneform wouldn’t be a package dependency any more and in the future someone would need to manually merge changes in there. But this was a step towards the good direction. I’d also need to duplicate this into any project I have. Besides a copy it still needed some more steps:
com.google.ar.sceneform.ux:sceneform-ux:1.17.0 implementation dependency needed to be removed from my gradle.build file, otherwise the included source code classes would collide with the package’s classes and I’d get a ton of duplicate classes errors during compile.
The included source directories needed to be refactored to use the AndroidX libraries instead of the older AppCompat ones. I saw that several of the 400+ forks of the SDK repository already did that. My approach is to make minimal set of changes however. versus forks seemingly applied their own code styles (indentation rules and other coding style changes): that tricks the diff tool to sense more change than semantically actually happening and would more likely cause a merge conflict in the future if ever the source gets patched and you need to bring that into your project.
These series of steps together solved the runtime errors. The fact that Sceneform SDK repository is in an archived state - sad and concerning.
Comments loading...
Cookie Consent
CloudFlare: __cfduid — Being CloudFlare protected site: this cannot be turned off!
StackExchange: prov — Cookie is set if and only if you click on the StackOverflow flair or icon.
Disqus: disqusauth, disqusauths, sessionid, disqus_unique, G_ENABLED_IDPS, G_AUTHUSER_H — Optional cookies, but needed for the post commenting feature.