google-ar / sceneform-android-sdk

Sceneform SDK for Android
https://developers.google.com/sceneform/develop/
Apache License 2.0
1.23k stars 603 forks source link

Render PreferenceScreen as ViewRenderable #250

Open ManuelTS opened 6 years ago

ManuelTS commented 6 years ago

I want to create an ARCore app as immersive as possible. This encompasses also Android settings of an app implemented in accordance to its material design. I tried to use a minimalist settings implementation to try it, res/xml/preferences.xml is:

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:a="http://schemas.android.com/apk/res/android"
    a:layout_width="wrap_content"
    a:layout_height="wrap_content"
    a:background="@color/colorPrimaryHalf"
    a:padding="@dimen/tile_padding">
    <SwitchPreference
        a:id="@+id/label"
        a:layout_width="wrap_content"
        a:layout_height="wrap_content"
        a:textColor="@color/textColorPrimary"
        a:layout_below="@+id/mainHeader"
        a:text="@string/pref_label"
        a:summaryOff="@string/pref_label_off"
        a:summaryOn="@string/pref_label_on"
        a:defaultValue="true"
        a:key="@string/pref_key_label"/>
</PreferenceScreen>

which gets loaded as the example code in Create Renderables#Create from Android widgets. I get the following exceptions:

08-10 11:14:35.380 10112-10112/at.mts.arnatomy.app E/MessageQueue-JNI: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class PreferenceScreen
    Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class PreferenceScreen
    Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.PreferenceScreen" on path: DexPathList[[zip file "/data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/base.apk", zip file "/data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/split_lib_dependencies_apk.apk", zip file "/data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/split_lib_resources_apk.apk", zip file "/data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/split_lib_slice_0_apk.apk", zip file "/data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/split_lib_slice_1_apk.apk", zip file "/data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/split_lib_slice_2_apk.apk", zip file "/data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/split_lib_slice_3_apk.apk", zip file "/data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/split_lib_slice_4_apk.apk", zip file "/data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/split_lib_slice_5_apk.apk", zip file "/data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/split_lib_slice_6_apk.apk", zip file "/data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/split_lib_slice_7_apk.apk", zip file "/data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/split_lib_slice_8_apk.apk", zip file "/data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/lib/arm64, /data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/base.apk!/lib/arm64-v8a, /data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/split_lib_dependencies_apk.apk!/lib/arm64-v8a, /data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/split_lib_resources_apk.apk!/lib/arm64-v8a, /data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/split_lib_slice_0_apk.apk!/lib/arm64-v8a, /data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/split_lib_slice_1_apk.apk!/lib/arm64-v8a, /data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/split_lib_slice_2_apk.apk!/lib/arm64-v8a, /data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/split_lib_slice_3_apk.apk!/lib/arm64-v8a, /data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/split_lib_slice_4_apk.apk!/lib/arm64-v8a, /data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/split_lib_slice_5_apk.apk!/lib/arm64-v8a, /data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/split_lib_slice_6_apk.apk!/lib/arm64-v8a, /data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/split_lib_slice_7_apk.apk!/lib/arm64-v8a, /data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/split_lib_slice_8_apk.apk!/lib/arm64-v8a, /data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/split_lib_slice_9_apk.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        at android.view.LayoutInflater.createView(LayoutInflater.java:606)
        at android.view.LayoutInflater.onCreateView(LayoutInflater.java:703)
        at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:68)
        at android.view.LayoutInflater.onCreateView(LayoutInflater.java:720)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:788)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
        at com.google.ar.sceneform.rendering.ViewRenderable$Builder.inflateViewFromResourceId(ViewRenderable.java:527)
        at com.google.ar.sceneform.rendering.ViewRenderable$Builder.makeRenderable(ViewRenderable.java:478)
        at com.google.ar.sceneform.rendering.ViewRenderable$Builder.makeRenderable(ViewRenderable.java:401)
        at com.google.ar.sceneform.rendering.Rendera
08-10 11:14:35.381 10112-10112/at.mts.arnatomy.app D/AndroidRuntime: Shutting down VM

    --------- beginning of crash
08-10 11:14:35.386 10112-10112/at.mts.arnatomy.app E/AndroidRuntime: FATAL EXCEPTION: main
    Process: at.mts.arnatomy.app, PID: 10112
    android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class PreferenceScreen
    Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class PreferenceScreen
    Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.PreferenceScreen" on path: DexPathList[[zip file "/data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/base.apk", zip file "/data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/split_lib_dependencies_apk.apk", zip file "/data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/split_lib_resources_apk.apk", zip file "/data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/split_lib_slice_0_apk.apk", zip file "/data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/split_lib_slice_1_apk.apk", zip file "/data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/split_lib_slice_2_apk.apk", zip file "/data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/split_lib_slice_3_apk.apk", zip file "/data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/split_lib_slice_4_apk.apk", zip file "/data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/split_lib_slice_5_apk.apk", zip file "/data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/split_lib_slice_6_apk.apk", zip file "/data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/split_lib_slice_7_apk.apk", zip file "/data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/split_lib_slice_8_apk.apk", zip file "/data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/lib/arm64, /data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/base.apk!/lib/arm64-v8a, /data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/split_lib_dependencies_apk.apk!/lib/arm64-v8a, /data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/split_lib_resources_apk.apk!/lib/arm64-v8a, /data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/split_lib_slice_0_apk.apk!/lib/arm64-v8a, /data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/split_lib_slice_1_apk.apk!/lib/arm64-v8a, /data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/split_lib_slice_2_apk.apk!/lib/arm64-v8a, /data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/split_lib_slice_3_apk.apk!/lib/arm64-v8a, /data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/split_lib_slice_4_apk.apk!/lib/arm64-v8a, /data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/split_lib_slice_5_apk.apk!/lib/arm64-v8a, /data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/split_lib_slice_6_apk.apk!/lib/arm64-v8a, /data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/split_lib_slice_7_apk.apk!/lib/arm64-v8a, /data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/split_lib_slice_8_apk.apk!/lib/arm64-v8a, /data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/split_lib_slice_9_apk.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        at android.view.LayoutInflater.createView(LayoutInflater.java:606)
        at android.view.LayoutInflater.onCreateView(LayoutInflater.java:703)
        at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:68)
        at android.view.LayoutInflater.onCreateView(LayoutInflater.java:720)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:788)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
        at com.google.ar.sceneform.rendering.ViewRenderable$Builder.inflateViewFromResourceId(ViewRenderable.java:527)
        at com.google.ar.sceneform.rendering.ViewRenderable$Builder.makeRenderable(ViewRenderable.java:478)
08-10 11:14:35.388 10112-10112/at.mts.arnatomy.app E/AndroidRuntime:     at com.google.ar.sceneform.rendering.ViewRenderable$Builder.makeRenderable(ViewRenderable.java:401)
        at com.google.ar.sceneform.rendering.Renderable$Builder.build(Renderable.java:328)
        at com.google.ar.sceneform.rendering.ViewRenderable$Builder.build(ViewRenderable.java:470)
        at at.mts.arnatomy.controller.ar.renderable.BaseView.<init>(BaseView.java:55)
        at at.mts.arnatomy.controller.ar.renderable.PreferencesView.<init>(PreferencesView.java:20)
        at at.mts.arnatomy.controller.ar.renderable.BaseView.build(BaseView.java:82)
        at at.mts.arnatomy.controller.ar.ARnatomyFragment.onFling(ARnatomyFragment.java:147)
        at android.view.GestureDetector.onTouchEvent(GestureDetector.java:655)
        at android.support.v4.view.GestureDetectorCompat$GestureDetectorCompatImplJellybeanMr2.onTouchEvent(GestureDetectorCompat.java:480)
        at android.support.v4.view.GestureDetectorCompat.onTouchEvent(GestureDetectorCompat.java:543)
        at at.mts.arnatomy.controller.ar.ARnatomyFragment.onPeekTouch(ARnatomyFragment.java:103)
        at com.google.ar.sceneform.TouchEventSystem.onTouchEvent(Unknown Source:42)
        at com.google.ar.sceneform.Scene.onTouchEvent(Unknown Source:11)
        at com.google.ar.sceneform.SceneView.onTouchEvent(Unknown Source:9)
        at android.view.View.dispatchTouchEvent(View.java:11788)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2979)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2668)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2979)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2668)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2979)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2668)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2979)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2668)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2979)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2668)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2979)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2668)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2979)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2668)
        at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:599)
        at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1839)
        at android.app.Activity.dispatchTouchEvent(Activity.java:3334)
        at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:68)
        at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:550)
        at android.view.View.dispatchPointerEvent(View.java:12027)
        at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4809)
        at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4623)
        at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4161)
        at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4214)
        at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4180)
        at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4307)
        at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4188)
        at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4364)
        at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4161)
        at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4214)
        at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4180)
        at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4188)
        at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4161)
        at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6682)
        at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6656)
        at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6617)
08-10 11:14:35.389 10112-10176/at.mts.arnatomy.app E/native: vio_state_types.h:178 Updated t_s is larger than expected, please increase max_allowed_t_s.
08-10 11:14:35.390 10112-10112/at.mts.arnatomy.app E/AndroidRuntime:     at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6785)
        at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:187)
        at android.os.MessageQueue.nativePollOnce(Native Method)
        at android.os.MessageQueue.next(MessageQueue.java:325)
        at android.os.Looper.loop(Looper.java:142)
        at android.app.ActivityThread.main(ActivityThread.java:6501)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
        Suppressed: java.io.IOException: No original dex files found for dex location /data/app/at.mts.arnatomy.app-yu0M9pZbKDRM5Dso7OuRGA==/split_lib_resources_apk.apk
        at dalvik.system.DexFile.openDexFileNative(Native Method)
        at dalvik.system.DexFile.openDexFile(DexFile.java:353)
        at dalvik.system.DexFile.<init>(DexFile.java:100)
        at dalvik.system.DexFile.<init>(DexFile.java:74)
        at dalvik.system.DexPathList.loadDexFile(DexPathList.java:374)
        at dalvik.system.DexPathList.makeDexElements(DexPathList.java:337)
        at dalvik.system.DexPathList.<init>(DexPathList.java:157)
        at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:65)
        at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:64)
        at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:73)
        at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:88)
        at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:69)
        at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:35)
        at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:693)
        at android.app.LoadedApk.getClassLoader(LoadedApk.java:727)
        at android.app.LoadedApk.getResources(LoadedApk.java:954)
        at android.app.ContextImpl.createAppContext(ContextImpl.java:2270)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5646)
        at android.app.ActivityThread.-wrap1(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:164)
                ... 4 more

Where

at at.mts.arnatomy.controller.ar.renderable.BaseView.<init>(BaseView.java:55)

points to the .build() of

ViewRenderable.builder().setSizer(new DpToMetersViewSizer(dp2MeterScale))
                    .setView(context, id)
                    .build()
                    .thenAccept(r -> {
                        this.renderable = r;
                        renderable.setShadowCaster(false);
                        renderable.setShadowReceiver(false);
                        onAfterLoad();
                    });

My conclusion is I have to implement the AR settings of my app on my own with standard Android components since AR Core does not support PreferenceScreen. As a feature request, will be AR core rendering of PreferenceScreen and all involved classes supported at all, and if yes when?

claywilkinson commented 6 years ago

Thanks for the detailed explanation of what you are trying to do and the issues you encountered! ViewRenderable works with the View hierarchy, and as you noticed, Preferences are not view based, so they do not work. So for now, if you want to use Preferences in the scene, you'll need to create your own layout and then populate the layout with your preferences. I have not tried, but you might be able to use PreferenceFragmentCompat to inflate it and pass the listview from the fragment to the viewRenderable?

I'll pass along the request to support Preferences directly.

ManuelTS commented 6 years ago

Using com.android.support:preference-v7:27.1.1 I get

08-11 14:34:49.843 6713-6713/at.mts.arnatomy.app E/ViewRenderable: Unable to load Renderable registryId='null'
    java.lang.AssertionError: ViewRenderable must have a source.
        at com.google.ar.sceneform.rendering.ViewRenderable$Builder.checkPreconditions(ViewRenderable.java:509)
        at com.google.ar.sceneform.rendering.Renderable$Builder.build(Renderable.java:305)
        at com.google.ar.sceneform.rendering.ViewRenderable$Builder.build(ViewRenderable.java:470)
        at at.mts.arnatomy.controller.ar.renderable.BaseView.<init>(BaseView.java:70)
        at at.mts.arnatomy.controller.ar.renderable.PreferencesView.<init>(PreferencesView.java:22)
        at at.mts.arnatomy.controller.ar.renderable.BaseView.build(BaseView.java:96)
        at at.mts.arnatomy.controller.ar.ARnatomyFragment.onFling(ARnatomyFragment.java:147)
        at android.view.GestureDetector.onTouchEvent(GestureDetector.java:655)
        at android.support.v4.view.GestureDetectorCompat$GestureDetectorCompatImplJellybeanMr2.onTouchEvent(GestureDetectorCompat.java:480)
        at android.support.v4.view.GestureDetectorCompat.onTouchEvent(GestureDetectorCompat.java:543)
        at at.mts.arnatomy.controller.ar.ARnatomyFragment.onPeekTouch(ARnatomyFragment.java:103)
        at com.google.ar.sceneform.TouchEventSystem.onTouchEvent(Unknown Source:42)
        at com.google.ar.sceneform.Scene.onTouchEvent(Unknown Source:11)
        at com.google.ar.sceneform.SceneView.onTouchEvent(Unknown Source:9)
        at android.view.View.dispatchTouchEvent(View.java:11788)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2979)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2668)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2979)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2668)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2979)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2668)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2979)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2668)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2979)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2668)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2979)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2668)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2979)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2668)
        at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:599)
        at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1839)
        at android.app.Activity.dispatchTouchEvent(Activity.java:3334)
        at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:68)
        at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:550)
        at android.view.View.dispatchPointerEvent(View.java:12027)
        at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4809)
        at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4623)
        at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4161)
        at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4214)
        at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4180)
        at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4307)
        at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4188)
        at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4364)
        at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4161)
        at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4214)
        at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4180)
        at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4188)
        at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4161)
        at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6682)
08-11 14:34:49.844 6713-6713/at.mts.arnatomy.app E/ViewRenderable:     at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6656)
        at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6617)
        at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6785)
        at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:187)
        at android.os.MessageQueue.nativePollOnce(Native Method)
        at android.os.MessageQueue.next(MessageQueue.java:325)
        at android.os.Looper.loop(Looper.java:142)
        at android.app.ActivityThread.main(ActivityThread.java:6501)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
08-11 14:34:49.866 6713-6713/at.mts.arnatomy.app W/System.err: java.util.concurrent.CompletionException: java.lang.AssertionError: ViewRenderable must have a source.
08-11 14:34:49.867 6713-6713/at.mts.arnatomy.app W/System.err:     at java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:294)
        at java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:310)
08-11 14:34:49.868 6713-6713/at.mts.arnatomy.app W/System.err:     at java.util.concurrent.CompletableFuture.uniAccept(CompletableFuture.java:655)
        at java.util.concurrent.CompletableFuture.uniAcceptStage(CompletableFuture.java:677)
        at java.util.concurrent.CompletableFuture.thenAccept(CompletableFuture.java:2023)
08-11 14:34:49.869 6713-6713/at.mts.arnatomy.app W/System.err:     at at.mts.arnatomy.controller.ar.renderable.BaseView.<init>(BaseView.java:71)
        at at.mts.arnatomy.controller.ar.renderable.PreferencesView.<init>(PreferencesView.java:22)
08-11 14:34:49.870 6713-6713/at.mts.arnatomy.app W/System.err:     at at.mts.arnatomy.controller.ar.renderable.BaseView.build(BaseView.java:96)
        at at.mts.arnatomy.controller.ar.ARnatomyFragment.onFling(ARnatomyFragment.java:147)
        at android.view.GestureDetector.onTouchEvent(GestureDetector.java:655)
        at android.support.v4.view.GestureDetectorCompat$GestureDetectorCompatImplJellybeanMr2.onTouchEvent(GestureDetectorCompat.java:480)
08-11 14:34:49.871 6713-6713/at.mts.arnatomy.app W/System.err:     at android.support.v4.view.GestureDetectorCompat.onTouchEvent(GestureDetectorCompat.java:543)
        at at.mts.arnatomy.controller.ar.ARnatomyFragment.onPeekTouch(ARnatomyFragment.java:103)
        at com.google.ar.sceneform.TouchEventSystem.onTouchEvent(Unknown Source:42)
        at com.google.ar.sceneform.Scene.onTouchEvent(Unknown Source:11)
        at com.google.ar.sceneform.SceneView.onTouchEvent(Unknown Source:9)
08-11 14:34:49.872 6713-6713/at.mts.arnatomy.app W/System.err:     at android.view.View.dispatchTouchEvent(View.java:11788)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2979)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2668)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2979)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2668)
08-11 14:34:49.873 6713-6713/at.mts.arnatomy.app W/System.err:     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2979)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2668)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2979)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2668)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2979)
08-11 14:34:49.874 6713-6713/at.mts.arnatomy.app W/System.err:     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2668)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2979)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2668)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2979)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2668)
08-11 14:34:49.875 6713-6713/at.mts.arnatomy.app W/System.err:     at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:599)
        at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1839)
        at android.app.Activity.dispatchTouchEvent(Activity.java:3334)
        at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:68)
        at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:550)
        at android.view.View.dispatchPointerEvent(View.java:12027)
08-11 14:34:49.876 6713-6713/at.mts.arnatomy.app W/System.err:     at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4809)
        at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4623)
        at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4161)
        at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4214)
        at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4180)
08-11 14:34:49.877 6713-6713/at.mts.arnatomy.app W/System.err:     at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4307)
        at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4188)
08-11 14:34:49.877 6713-6713/at.mts.arnatomy.app W/System.err:     at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4364)
        at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4161)
        at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4214)
        at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4180)
08-11 14:34:49.878 6713-6713/at.mts.arnatomy.app W/System.err:     at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4188)
        at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4161)
        at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6682)
        at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6656)
        at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6617)
        at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6785)
        at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:187)
        at android.os.MessageQueue.nativePollOnce(Native Method)
08-11 14:34:49.879 6713-6713/at.mts.arnatomy.app W/System.err:     at android.os.MessageQueue.next(MessageQueue.java:325)
        at android.os.Looper.loop(Looper.java:142)
        at android.app.ActivityThread.main(ActivityThread.java:6501)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
08-11 14:34:49.880 6713-6713/at.mts.arnatomy.app W/System.err: Caused by: java.lang.AssertionError: ViewRenderable must have a source.
08-11 14:34:49.881 6713-6713/at.mts.arnatomy.app W/System.err:     at com.google.ar.sceneform.rendering.ViewRenderable$Builder.checkPreconditions(ViewRenderable.java:509)
        at com.google.ar.sceneform.rendering.Renderable$Builder.build(Renderable.java:305)
        at com.google.ar.sceneform.rendering.ViewRenderable$Builder.build(ViewRenderable.java:470)
        at at.mts.arnatomy.controller.ar.renderable.BaseView.<init>(BaseView.java:70)
        ... 56 more

again on .build() when i use

PreferencesView.PrefsFragment pf = new PreferencesView.PrefsFragment();
ViewRenderable.builder()
  .setSizer(new DpToMetersViewSizer(dp2MeterScale))
  .setView(context, pf.getListView())
  .build()
  .thenAccept(r -> {
    this.renderable = r;
    renderable.setShadowCaster(false);
    renderable.setShadowReceiver(false);})
  .thenRun(()-> onAfterLoad())
  .exceptionally(t -> {
    Toast.makeText(context, "Unable to load view renderable", Toast.LENGTH_LONG).show();
     t.printStackTrace();
     return null;
});

Where PrefsFragment is exactly implemented in PreferenceView as in the docs:

public static class PrefsFragment extends PreferenceFragmentCompat {

    @Override
    public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
        // Load the preferences from an XML resource
        setPreferencesFromResource(R.xml.preferences, rootKey);
    }
}