添加无法解决的场景格式1.16时出错

问题描述

我关注了: https://github.com/google-ar/sceneform-android-sdk

添加

Finally,add a reference to the SceneForm SDK to your app's build.gradle:
dependencies {
    api project(":SceneFormux")
}

但是我遇到了错误

Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve project :SceneFormux.

我什么都没穿。

按照步骤操作后,我也收到错误消息,指出以下内容不存在。

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.BaseArFragment;
import com.google.ar.SceneForm.ux.TransformableNode;
import com.google.ar.SceneForm.math.Quaternion;
import com.google.ar.SceneForm.math.Vector3;

解决方法

这看起来像您的 Android Studio 找不到sceneformux 模块。

您可以按照您共享的链接中的步骤将其添加到您的项目中 - 特别是:

  1. 从 Sceneform SDK 发布页面下载 sceneform-android-sdk-1.16.0.zip。
  2. 将sceneformsrc 和sceneformux 目录解压到项目的顶级目录中。生成的目录结构应类似于以下内容:

项目
+-- 应用
+-- build.gradle
+-- ...
+--sceneformsrc
+--sceneformux
+-- build.gradle
+-- settings.gradle
+-- ...

  1. 修改项目的 settings.gradle 以包含 Sceneform 项目: 包括':app'

// 添加以下几行:
包括 ':sceneform'
project(':sceneform').projectDir=new File('sceneformsrc/sceneform')

包含':sceneformux'
project(':sceneformux').projectDir=new File('sceneformux/ux')

  1. 最后,向您的应用的 build.gradle 添加对 Sceneform SDK 的引用: 依赖{ api 项目(“:sceneformux”) }

假设你做了以上所有,那么可能只是Android studio没有同步到完全识别你复制到项目中的目录sceneformsrc和sceneformux。

您现在很可能已经解决了这个问题,但为了完整起见,我看到了类似的东西,虽然 Android Studio 中可能有更精确的同步选项来解决这个问题,但我发现退出 Android Studio 并重新启动它通常会清除这种类型问题,在这种情况下也为我做了。