android-studio - 导入 Sceneform Assets 不会生成 .sfa 和 .sfb 文件

标签 android-studio import assets arcore sceneform

当我尝试导入场景形式 Assets 并在弹出的窗口上按完成时,没有任何 react 。没有生成 .sfa、.sfb 文件。在 build.gradle 文件中也没有生成任何内容。我不得不提到我导入的之前在同一个项目中的场景 Assets ,一切正常,但现在(一段时间后)当我再次尝试这样做时,它不起作用。

最佳答案

来自 https://developers.google.com/sceneform/develop/
enter image description here
考虑到 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 Assets 及其依赖项(obj、mtl、fbx、png)放入 sampledata 目录中。
  • 将 classpath '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 >
    
  • 我已添加 Mars 3D asset来自 Poly到我的样本数据。目录结构类似于 enter image description here
  • 将原始数据目录添加到资源中。
    右键单击 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) - Release Notes
    该文档仅适用于 sceneform 1.15.0——不包括 glTF 工作流程。您可以查看 this使用 glTF 的演示。

    关于android-studio - 导入 Sceneform Assets 不会生成 .sfa 和 .sfb 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62124242/

    相关文章:

    java - Android:NoClassDefFoundError 仅适用于发布版本

    php - Symfony2 创建自定义资源的符号链接(symbolic link)

    android - 使用 Gradle 0.9 和 Android Studio 的 Robotium 测试用例,迁移到 Gradle 0.9 失败

    go - 在导入包时出现此错误知道如何解决这个问题吗?

    python - 如何解决无限循环导入?

    c - 有没有办法在包含同时具有数据和时间的列的数据文件中分隔列

    Android:使用 Assets 文件时出现 ZipFile、FileNotFoundException

    javascript - CakePHP Assets 压缩: Not generating compressed files in cache folders

    java - Android Studio 3.6 Canary 12 XML 布局无法解析

    Android Studio 项目编码错误