【问题标题】:How do I update my ARCore to the version 1.12.0?如何将我的 ARCore 更新到 1.12.0 版本?
【发布时间】:2021-08-15 01:27:24
【问题描述】:

我正在 Android Studio 中使用 ARCore 学习增强现实。我尝试按照 YouTube 教程进行操作,即使按照说明进行了所有操作,当我尝试打开应用程序时,它还是崩溃了。

在 Logcat 中,我收到以下错误消息:

2021-05-27 00:07:27.689 25976-25976/com.example.basicone E/Filament: Panic
    in void *filament::CircularBuffer::alloc(size_t):127
    reason: couldn't allocate 6144 KiB of memory for the command buffer
2021-05-27 00:07:27.689 25976-25976/com.example.basicone A/libc: Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 25976 (xample.basicone), pid 25976 (xample.basicone)

我在网上搜索解决方案时看到了一个 GitHub 问题页面:https://github.com/Esri/arcgis-runtime-toolkit-android/issues/143 其中提到更新到 ARCore 1.12.0 以解决灯丝错误。

我想知道我该怎么做?将 ARCore 更新到最新版本可以解决问题吗?如果是,那我该怎么做?

以下是我的代码:

MainActivity.java

import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;

import android.net.Uri;
import android.os.Bundle;

import com.google.ar.core.Anchor;
import com.google.ar.sceneform.AnchorNode;
import com.google.ar.sceneform.rendering.ModelRenderable;
import com.google.ar.sceneform.ux.ArFragment;
import com.google.ar.sceneform.ux.TransformableNode;

public class MainActivity extends AppCompatActivity {

    private ArFragment arFragment;

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

        arFragment = (ArFragment) getSupportFragmentManager()
                .findFragmentById(R.id.arFragment);

        arFragment.setOnTapArPlaneListener((hitResult, plane, motionEvent) -> {
            Anchor anchor = hitResult.createAnchor();

            ModelRenderable.builder()
                    .setSource(this, Uri.parse("jeep_model.sfb"))
                    .build()
                    .thenAccept(modelRenderable -> addModelToScene(anchor, modelRenderable))
                    .exceptionally(throwable -> {
                        AlertDialog.Builder builder = new AlertDialog.Builder(this);
                        builder.setMessage(throwable.getMessage())
                                .show();
                        return null;
                    });
        });
    }

    private void addModelToScene(Anchor anchor, ModelRenderable modelRenderable) {
        AnchorNode anchorNode = new AnchorNode(anchor);
//        AnchorNode automatically positions real world space based on anchor
        TransformableNode transformableNode = new TransformableNode(arFragment.getTransformationSystem());
        transformableNode.setParent(anchorNode);
        transformableNode.setRenderable(modelRenderable);
        arFragment.getArSceneView()
                .getScene()
                .addChild(anchorNode);
//        Always the parent should be passed

        transformableNode.select();
    }
}

build.gradle(模块:app)

dependencies {
...
   implementation 'com.google.ar.sceneform.ux:sceneform-ux:1.5.1'
}

清单

<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera.ar" android:required="true" />

<meta-data android:name="com.google.ar.core" android:value="required" />

提前致谢

【问题讨论】:

    标签: android augmented-reality arcore sceneform


    【解决方案1】:

    我认为问题在于 .sfb 文件支持。 Android Studio 使用 Sceneform 插件将模型转换为 .sfb 格式。这个插件不再支持了,我相信你可以将你的 Android Studio 降级到 3.4 或 3.2。或者只是使用gltf文件格式和新的sceneform版本

    【讨论】:

    • 我使用的是 Android Studio 3.5,Sceneform 应该可以正常工作。因为,在我的其他项目中,Sceneform 方面没有任何问题。
    【解决方案2】:

    是的,你完全正确。手动将您的 ARCore 更新到 1.12.0 版可修复灯丝恐慌问题。我记得2019年的那个问题。下载ARCore SDK for Android v1.12.0并按照instructions进行设置。

    P.S. 由于 Sceneform 已弃用且 ARCore 早期版本不受支持,因此不确定是否可以通过 Android Studio 的 UI 进行此类更新。但是你应该试试。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-01
      • 2016-11-03
      • 2016-03-06
      • 2013-07-12
      • 2014-05-01
      相关资源
      最近更新 更多