SceneView / sceneform-android

Sceneform Maintained is an ARCore Android SDK with Google Filament as 3D engine. This is the continuation of the archived Sceneform
https://sceneview.github.io/sceneform-android/
Apache License 2.0
615 stars 143 forks source link

(Java) App crashes on device #472

Open dhatriparakal opened 2 weeks ago

dhatriparakal commented 2 weeks ago

My app keeps crashing (testing on a Samsung Galaxy Tab S9+). I followed the tutorial here, it's also in the readme.md file: https://medium.com/make-an-android-ar-augmented-reality-app-for/make-an-ar-augmented-reality-app-for-android-in-2022-48a1711562bb

I'm using java instead of kotlin though, I'm not sure if that would cause any problems? This is my MainActivity.java for reference:

public class MainActivity extends AppCompatActivity {

    ArFragment arFragment;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // Load model.glb from assets folder or http url
        arFragment = (ArFragment) getSupportFragmentManager().findFragmentById(R.id.arFragment);
        if (arFragment != null) {
            arFragment.setOnTapPlaneGlbModel("model.glb");
        }
        //arFragment.setOnTapPlaneGlbModel("https://github.com/codemaker2015/3d-models/blob/master/glb_files/model.glb?raw=true");

    }

These are my error logs:

Process: com.example.minimalarwcamera, PID: 6599
java.lang.NoSuchMethodError: No virtual method acquireEnvironmentalHdrCubeMap()[Lcom/google/ar/core/ArImage; in class Lcom/google/ar/core/LightEstimate; or its super classes (declaration of 'com.google.ar.core.LightEstimate' appears in /data/app/~~42uQ2fjSsRLO0eDYv_fBdg==/com.example.minimalarwcamera-Jt3Ovib2PRvM3NHJKkRdiQ==/base.apk)
                at com.gorisse.thomas.sceneform.light.LightEstimationKt.environmentalHdrEnvironmentLights(LightEstimation.kt:394)
                at com.gorisse.thomas.sceneform.light.LightEstimationKt.environmentLightsEstimate(LightEstimation.kt:225)
                at com.google.ar.sceneform.ArSceneView.onBeginFrame(ArSceneView.java:527)
                at com.google.ar.sceneform.SceneView.doFrameNoRepost(SceneView.java:466)
                at com.google.ar.sceneform.SceneView.doFrame(SceneView.java:450)
                at com.google.ar.sceneform.ArSceneView.doFrame(ArSceneView.java:552)
                at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1687)
                at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1698)
                at android.view.Choreographer.doCallbacks(Choreographer.java:1153)
                at android.view.Choreographer.doFrame(Choreographer.java:1069)
                at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1646)
                at android.os.Handler.handleCallback(Handler.java:958)
                at android.os.Handler.dispatchMessage(Handler.java:99)
                at android.os.Looper.loopOnce(Looper.java:230)
                at android.os.Looper.loop(Looper.java:319)
                at android.app.ActivityThread.main(ActivityThread.java:8934)
                at java.lang.reflect.Method.invoke(Native Method)
                at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:578)
                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
dhatriparakal commented 2 weeks ago

I saw similar errors for others, and some said it was Android 14 related - I just ran my app on an Android 13 emulator and got the same error.

Mehequanna commented 1 week ago

Is AR Core able to run on emulators now? If so, I'd love to hear how.

Mehequanna commented 1 week ago

As for the error, we chatted about this in the Discord group. This is caused by using a mismatched version of ARCore and Sceneform. When using a specific Sceneform Maintained version, it's best to use the same ARCore version the release does. So in this case, com.gorisse.thomas.sceneform:sceneform:1.23.0 is using ARCore version 1.31.0 https://github.com/SceneView/sceneform-android/blob/62a371f1495d1800a279ff43645945c758f3bbbf/build.gradle#L19

Mehequanna commented 1 week ago

This issue is the same as #463

dhatriparakal commented 1 week ago

Is AR Core able to run on emulators now? If so, I'd love to hear how.

I think this error is occuring before ARCore even gets a chance to attempt running on the device, since it crashes immediately after starting. I'm not entirely sure though. Also I think there is a way to use emulators for ARCore but I haven't made any serious attempts at it.

dhatriparakal commented 1 week ago

As for the error, we chatted about this in the Discord group. This is caused by using a mismatched version of ARCore and Sceneform. When using a specific Sceneform Maintained version, it's best to use the same ARCore version the release does. So in this case, com.gorisse.thomas.sceneform:sceneform:1.23.0 is using ARCore version 1.31.0

https://github.com/SceneView/sceneform-android/blob/62a371f1495d1800a279ff43645945c758f3bbbf/build.gradle#L19

Ahh I see, that makes sense - I'll try that and see if it works