如何解决如何将我的 ARCore 更新到 1.12.0 版?
我正在 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" />
提前致谢
解决方法
我认为问题在于 .sfb 文件支持。 Android Studio 使用 Sceneform 插件将模型转换为 .sfb 格式。不再支持此插件,我相信您可以将您的 Android Studio 降级到 3.4 或 3.2。或者直接使用gltf文件格式和新的sceneform版本
,是的,你完全正确。手动将您的 ARCore 更新到 1.12.0 版修复了 Filament 恐慌的问题。我记得 2019 年的那个问题。下载 ARCore SDK for Android v1.12.0 并按照 instructions 进行设置。
P.S. 不确定是否可以通过 Android Studio 的 UI 进行此类更新,因为 Sceneform 已弃用且 ARCore 的早期版本不受支持。但你应该试试。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。