导入Sceneform资产不会生成.sfa和.sfb文件

时间:2020-06-01 00:55:26

标签: android-studio import assets arcore sceneform

当我尝试导入场景形式资产并在弹出的窗口上按完成时,什么也没有发生。没有生成.sfa,.sfb文件。还没有在build.gradle文件中生成任何内容。我不得不提我以前在同一项目中导入了场景形式资产,并且一切正常,但是现在(一段时间后)当我再次尝试进行操作时不起作用。

3 个答案:

答案 0 :(得分:2)

来自https://developers.google.com/sceneform/develop/

enter image description here

考虑到1.15和1.17.1相同,并且这些问题

看来它不再在开发中了,他们不会修复它。 android studio 3.6及更高版本存在问题。


没有解决方案,您可以回滚至Android Studio 3.5,也可以使用快速解决方法。

  1. 在应用程序中创建一个新的sampledata目录。

    右键单击顶级应用程序目录>新建>示例数据目录

  2. 将您的3D资产及其依赖项(obj,mtl,fbx,png)放入sampledata目录。

  3. 将类路径'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
         }
    }
    
  4. 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 >
    
  5. 我已将Mars 3D asset中的Poly添加到我的样本数据中。目录结构类似于enter image description here

  6. 将原始数据目录添加到资源。
    右键单击res>新建>文件夹> Raw resources文件夹。

  7. 将此添加到应用程序级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')
    
  8. 同步文件,它现在应该可以正常工作。

Sceneform已弃用对SFB和SFB Sceneform Android Studio插件的支持(可以改用glTF)-Release Notes

该文档仅适用于Sceneform 1.15.0-不包括glTF工作流程。您可以查看this演示以使用glTF。

答案 1 :(得分:0)

Sceneform 1.16和1.17 only supports gltf

As part of the 1.16.0 release, support for SFA and SFB assets was removed in favor of adding glTF support

Android Studio 3.6和Sceneform Tools中还存在一个错误,该错误会使Android Studio崩溃(将AS降级为3.5会有所帮助)。 如果要使用.fbx,则应降级到Sceneform 1.15,或者可以使用Sceneform 1.17和gltf格式

答案 2 :(得分:0)

我遇到了同样的问题,我注意到您可以通过在build.gradle中添加带有sceneform.asset(...)的模型并构建项目(相关的.sfa和.sfb文件)而无需插件的情况下然后创建。