android-studio - 导入 Sceneform 资产不会生成 .sfa 和 .sfb 文件
问题描述
当我尝试导入sceneform资产并在弹出的窗口上按完成时,没有任何反应。没有.sfa,.sfb文件生成。build.gradle文件中也没有生成任何东西。我不得不提到我导入了以前在同一个项目中的sceneform资产一切正常,但现在(一段时间后)当我再次尝试时它不起作用。
解决方案
来自https://developers.google.com/sceneform/develop/
考虑到1.15和1.17.1相同,还有这些问题
- https://github.com/google-ar/sceneform-android-sdk/issues/1078
- https://github.com/google-ar/sceneform-android-sdk/issues/989
- https://github.com/google-ar/sceneform-android-sdk/issues/912
看起来它不再处于开发阶段,他们也不会修复它。这是 android studio 3.6 及更高版本的问题。
没有解决方案,要么您可以回滚到 Android Studio 3.5,要么您可以使用快速解决方法。
在您的应用程序中创建一个新的 sampledata 目录。
右键单击顶级应用程序级目录 > 新建 > 示例数据目录
将您的 3D 资产及其依赖项(obj、mtl、fbx、png)放入 sampledata 目录。
将类路径 'com.google.ar.sceneform:plugin:1.15.0' 添加到您的项目级 gradle。确保您在存储库中有 google() 。
// Top-level build file where you can add configuration options. common to all sub-projects/modules buildscript { repositories { google() jcenter() } dependencies { classpath "com.android.tools.build:gradle:4.0.1" classpath 'com.google.ar.sceneform:plugin:1.15.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } }
Sceneform 需要特定版本的 NDK 和 Java。并且您需要应用插件和依赖项,因为它不会自动添加到最新版本的 android studio 中。应用插件:'com.android.application' 应用插件:'com.google.ar.sceneform.plugin'
android { ... defaultConfig { ... ndk { /* * Sceneform is available for the following ABIs: arm64-v8a, armv7a, * x86_64 and x86. This sample app enables arm64-v8a to run on * devices and x86 to run on the emulator. Your application should * list the ABIs most appropriate to minimize APK size (arm64-v8a recommended). */ abiFilters 'arm64-v8a', 'x86' } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } } buildTypes { ... } } dependencies { ... implementation 'com.google.ar.sceneform:core:1.15.0' } < sceneform.asset code - 7th step >
我已将Poly中的Mars 3D 资产添加到我的示例数据中。目录结构看起来像
将原始数据目录添加到资源。
右键单击 res > 新建 > 文件夹 > 原始资源文件夹。将此添加到应用程序级 gradle 文件的末尾。
sceneform.asset('sampledata/mars.obj', // 'Source Asset Path' specified during import. 'default', // 'Material Path' specified during import. 'sampledata/mars.sfa', // '.sfa Output Path' specified during import. 'src/main/res/raw/mars')
同步文件,它现在应该可以工作了。
Sceneform 已弃用对 SFB 和 SFB Sceneform Android Studio 插件的支持(可以使用 glTF) -发行说明
该文档仅适用于 sceneform 1.15.0——不包括 glTF 工作流程。您可以查看此演示以了解如何使用 glTF。
推荐阅读
- logstash - 在 Logstash 中发送一个字段作为根字段
- python - 从 .pb 文件加载经过 TensorRT 优化的 TensorFlow 图的时间极长(超过 10 分钟)
- javascript - 在 Node js/Mochausing 中加载 json 文件内容需要模块动态传递文件名
- javascript - WordPress主题中的if else语句
- excel - 打开 Excel 文件,使用 Outlook VBA 将数据导入该文件
- c# - Twiml 出站呼叫
- python - 使用 gluLookAt() 会导致对象旋转
- architecture - 作为聚合根的自引用类
- c++ - 如何在 Windows 10 上修复 Visual Studio 2017 中特定于计算机的幻像 IntelliSense 错误?
- sql - 将 Find Dupes 查询转换为 Delete Dupes 查询