Sceneform-android-sdk: Error inflating ArSceneView on Pixel 2 XL

Created on 11 Jul 2018  路  14Comments  路  Source: google-ar/sceneform-android-sdk

EDIT: I got it running. The portion of the tutorial for adding ARCore & requesting permissions is easy to miss and also out of date.

I can run the sceneform sample app on this device without a problem. My device shows its OpenGL version as 3.2. I get this when I try to put an ArFragment in my main activity's layout.

 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.carterhudson.dtwenty/com.carterhudson.dtwenty.MainActivity}: android.view.InflateException: Binary XML file line #6: Binary XML file line #22: Binary XML file line #22: Error inflating class com.google.ar.sceneform.ArSceneView
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
        at android.app.ActivityThread.-wrap11(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6494)
        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)
     Caused by: android.view.InflateException: Binary XML file line #6: Binary XML file line #22: Binary XML file line #22: Error inflating class com.google.ar.sceneform.ArSceneView
     Caused by: android.view.InflateException: Binary XML file line #22: Binary XML file line #22: Error inflating class com.google.ar.sceneform.ArSceneView
     Caused by: android.view.InflateException: Binary XML file line #22: Error inflating class com.google.ar.sceneform.ArSceneView
     Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Constructor.newInstance0(Native Method)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
        at android.view.LayoutInflater.createView(LayoutInflater.java:647)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
        at com.google.ar.sceneform.ux.BaseArFragment.onCreateView(BaseArFragment.java:153)
        at android.support.v4.app.Fragment.performCreateView(Fragment.java:2346)
        at android.support.v4.app.FragmentManagerImpl.ensureInflatedFragmentView(FragmentManager.java:1664)
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1399)
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1659)
        at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1905)
        at android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:3715)
        at android.support.v4.app.FragmentController.onCreateView(FragmentController.java:114)
        at android.support.v4.app.FragmentActivity.dispatchFragmentsOnCreateView(FragmentActivity.java:374)
        at android.support.v4.app.BaseFragmentActivityApi14.onCreateView(BaseFragmentActivityApi14.java:39)
        at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:68)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:780)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
        at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
        at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
        at com.carterhudson.dtwenty.MainActivity.onCreate(MainActivity.kt:17)
        at android.app.Activity.performCreate(Activity.java:7009)
        at android.app.Activity.performCreate(Activity.java:7000)
07-11 12:04:51.878 4633-4633/com.carterhudson.dtwenty E/AndroidRuntime:     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
        at android.app.ActivityThread.-wrap11(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6494)
        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)
     Caused by: java.lang.BootstrapMethodError: Exception from call site #36 bootstrap method
        at com.google.ar.sceneform.rendering.LightProbe.loadInBackground(LightProbe.java:196)
        at com.google.ar.sceneform.rendering.LightProbe.access$400(LightProbe.java:37)
        at com.google.ar.sceneform.rendering.LightProbe$Builder.build(LightProbe.java:362)
        at com.google.ar.sceneform.Scene.setupLightProbe(Unknown Source:25)
        at com.google.ar.sceneform.Scene.<init>(Unknown Source:51)
        at com.google.ar.sceneform.SceneView.initialize(Unknown Source:49)
        at com.google.ar.sceneform.SceneView.<init>(Unknown Source:39)
        at com.google.ar.sceneform.ArSceneView.<init>(Unknown Source:0)
            ... 43 more
     Caused by: java.lang.NoClassDefFoundError: Invalid descriptor: chronometer.
            ... 51 more

Most helpful comment

Alright, adding in the compatibility compile options appears to have resolved the issue...

android {
    // Sceneform libraries use language constructs from Java 8.
    // Add these compile options if targeting minSdkVersion < 26.
    compileOptions {
        sourceCompatibility 1.8
        targetCompatibility 1.8
    }
}

It might be worth updating the documentation on the Sceneform Quickstart page (https://developers.google.com/ar/develop/java/quickstart), since I had set minSdkVersion 26 and the documentation led me to believe those options were unnecessary.

Also, I wonder if a more intuitive error could be caught and rethrown in this instance? I'm guessing people are getting stuck on this from time to time.

All 14 comments

did you add Java 8 compatibility in your app gradle file?

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

I believe that that is already in the app gradle file. I am getting the same errors and it seems it is an OpenGL ES problem wherein adroid studio only goes up to OpenGL 2 instead of 4.6. Is there an update on fixing this issue?

@carterhudson I'd be interested in updating any out of date documentation. Could you point me to the problematic doc/section ?

@AxesandGrinds we're tracking OpenGL ES Version requirement at https://github.com/google-ar/sceneform-android-sdk/issues/4 but we are lowering the requirement from 3.1 to 3.0 in an upcoming release.

@malik-at-work , do you mean in the sceneform1.4 release or a release after that? When can we expect the next release?

I can't give specific dates. This is expected imminently, but will go through our normal release process and can be delayed for dozens of reasons.

Imminently would be amazing. As soon as Sceneform is working correctly, a new world of AR opens up for android. It's bound to be epic. We're just waiting on you guys now. Thanks for this knowledge.

Hey @AxesandGrinds, Sceneform 1.4 is now available which supports OpenGL ES 3.0. Can you give the new version a try?

Closing this issue, please reopen or create a new issue if you're still encountering it with Sceneform 1.4.

I've been experiencing an issue that looks similar to this one since starting development a few weeks ago. I haven't been able to determine reproduction steps so far, but it does seem to be occurring after I've gone through importing a new Sceneform asset.

Oddly enough, the issue disappeared at some point after I played around with a few of the recommendations on this thread, but has since returned after attempting to import a new model. The error log appears related to some internal usage of the reflection API, so I'm not sure where the problem is.

Phone Model: Pixel 2
Android OS: 9.0 (Pie)
Sceneform: 1.5.1
ARCore: 1.5.0

java.lang.RuntimeException: Unable to start activity ComponentInfo{<app>.ArActivity}: android.view.InflateException: Binary XML file line #8: Binary XML file line #22: Binary XML file line #22: Error inflating class com.google.ar.sceneform.ArSceneView
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6669)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
     Caused by: android.view.InflateException: Binary XML file line #8: Binary XML file line #22: Binary XML file line #22: Error inflating class com.google.ar.sceneform.ArSceneView
     Caused by: android.view.InflateException: Binary XML file line #22: Binary XML file line #22: Error inflating class com.google.ar.sceneform.ArSceneView
     Caused by: android.view.InflateException: Binary XML file line #22: Error inflating class com.google.ar.sceneform.ArSceneView
     Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Constructor.newInstance0(Native Method)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
        at android.view.LayoutInflater.createView(LayoutInflater.java:647)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
        at com.google.ar.sceneform.ux.BaseArFragment.onCreateView(BaseArFragment.java:126)
        at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2439)
        at androidx.fragment.app.FragmentManagerImpl.ensureInflatedFragmentView(FragmentManager.java:1689)
        at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManager.java:1431)
        at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManager.java:1684)
        at androidx.fragment.app.FragmentManagerImpl.addFragment(FragmentManager.java:1930)
        at androidx.fragment.app.FragmentManagerImpl.onCreateView(FragmentManager.java:3745)
        at androidx.fragment.app.FragmentController.onCreateView(FragmentController.java:120)
        at androidx.fragment.app.FragmentActivity.dispatchFragmentsOnCreateView(FragmentActivity.java:405)
        at androidx.fragment.app.FragmentActivity.onCreateView(FragmentActivity.java:387)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:780)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
        at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
        at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
2018-11-19 12:57:34.960 32696-32696/? E/AndroidRuntime:     at <app>.ArActivity.onCreate(ArActivity.kt:19)
        at android.app.Activity.performCreate(Activity.java:7136)
        at android.app.Activity.performCreate(Activity.java:7127)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6669)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
     Caused by: java.lang.BootstrapMethodError: Exception from call site #8 bootstrap method
        at com.google.ar.sceneform.rendering.LightProbe.loadInBackground(LightProbe.java:196)
        at com.google.ar.sceneform.rendering.LightProbe.access$400(LightProbe.java:37)
        at com.google.ar.sceneform.rendering.LightProbe$Builder.build(LightProbe.java:362)
        at com.google.ar.sceneform.Scene.setupLightProbe(Unknown Source:43)
        at com.google.ar.sceneform.Scene.<init>(Unknown Source:58)
        at com.google.ar.sceneform.SceneView.initialize(Unknown Source:49)
        at com.google.ar.sceneform.SceneView.<init>(Unknown Source:39)
        at com.google.ar.sceneform.ArSceneView.<init>(Unknown Source:0)
            ... 44 more
     Caused by: java.lang.ClassCastException: Bootstrap method returned null
            ... 52 more

Potentially of interest might be my use of the new AndroidX libraries ('androidx.appcompat:appcompat:1.0.2') and Jetifier plugin?

For context, line 19 of the ArActivity is a call to...

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    ...
19> setContentView(R.layout.layout_ar)
    ...
}

...and that layout looks like this...

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <fragment
        android:name="com.google.ar.sceneform.ux.ArFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

</FrameLayout>

Please help!

Notably, if I checkout an older version of the codebase where the ArSceneView was being inflated without issue and try to run the app it is now crashing!

A couple of odd observations:

  • The AndroidX library has no impact upon the crash, with the crash still occurring with the android.support.v4.app library
  • The crash is occurring on old versions of the codebase that were previously working (I triple-checked a few different versions in order to be 100% sure), even after uninstalling and reinstalling a newly built .apk
  • I can sync the gradle files successfully, but attempting to clean or rebuild the project results in a compile-time failure while searching for a generated gradle task (compileAsset-src_47main_47assets_47scene_95air) that relates to an asset that doesn't exist in the older versions of the codebase! (IDE screenshot attached)
  • Running ./gradlew build through the command line fixes the compile-time failure upon rebuilding / cleaning through Android Studio, but a freshly deployed .apk (even one generated through ./gradlew assembleDebug on the command line) exhibits the same crash log
  • Restarting Android Studio has no effect on the crash
  • Proguard notes an issue that looks related...
    Note: kotlin.jvm.internal.Reflection: can't find dynamically referenced class kotlin.reflect.jvm.internal.ReflectionFactoryImpl
    ...however the app crashes even on builds where Proguard hasn't been run

What is going on!? 馃槙

screen shot 2018-11-19 at 1 43 37 pm

Debugging reveals that neither of the ArSceneViews constructors are called before the crash occurs. Could the issue be because ArSceneView lacks a zero-argument constructor to be called by java.lang.reflect.Constructor.newInstance0(Native Method)? I'm not sure why it would have been working on previous builds in that case.

Alright, adding in the compatibility compile options appears to have resolved the issue...

android {
    // Sceneform libraries use language constructs from Java 8.
    // Add these compile options if targeting minSdkVersion < 26.
    compileOptions {
        sourceCompatibility 1.8
        targetCompatibility 1.8
    }
}

It might be worth updating the documentation on the Sceneform Quickstart page (https://developers.google.com/ar/develop/java/quickstart), since I had set minSdkVersion 26 and the documentation led me to believe those options were unnecessary.

Also, I wonder if a more intuitive error could be caught and rethrown in this instance? I'm guessing people are getting stuck on this from time to time.

Facing the same issue and didn't get resolved using compileOptions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

PaulTVungle picture PaulTVungle  路  3Comments

hcjung2000 picture hcjung2000  路  3Comments

LukasStancikas picture LukasStancikas  路  3Comments

rohitagarwal3011 picture rohitagarwal3011  路  4Comments

michaelvogt picture michaelvogt  路  4Comments