Gradle 构建失败,新的导入规则 [英] Gradle build failed with new import rules

查看:37
本文介绍了Gradle 构建失败,新的导入规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将 android studio 更新到 3.6 版后遇到错误.当我尝试导入Scenceform资产时,它在下图中显示警告,无论我点击什么,它都会返回

I met an error after I updated android studio to version 3.6. When I tried to import Scenceform asset, it shows a warning in the picture below, whatever I click, it will return

java.lang.RuntimeException: java.lang.NoSuchMethodError: com.android.tools.idea.templates.recipe.RecipeExecutor.append(Ljava/io/File;Ljava/io/File;)

java.lang.RuntimeException: java.lang.NoSuchMethodError: com.android.tools.idea.templates.recipe.RecipeExecutor.append(Ljava/io/File;Ljava/io/File;)

我该如何解决这个问题?

How can I fix this?

推荐答案

-- 2020 年 6 月更新 --

Sceneform 1.15 已被开源的 Sceneform 1.16 取代.这似乎也改变了模型构建方法,不再使用 SceneForm 插件和 .sfa/.sfb 工作流程,而是直接支持 .gltf 格式模型.

Sceneform 1.15 has been replaced by the open source Sceneform 1.16. This appears to have also changed the model build approach, no longer using the SceneForm plugin and .sfa/.sfb workflow and instead including direct support for .gltf format model.

GitHub 页面上提供了更多信息,尽管存储库现已存档,这使得目前(2020 年 6 月)很难了解 Sceneform 的未来发展方向:

More information is available on the GitHub page, although the respoitory has now been archived which makes it hard to understand the future direction for Sceneform at this time (June 2020):

(https://github.com/google-ar/sceneform-android-sdk)

-- 如果您使用的是 Sceneform 1.15,则解决原始问题的方法 --

要解决此问题,您正在使用 Sceneform 插件 - 见下文:

To workaround the issue is you are using the Sceneform Plugin - see below:

在撰写本文时,这似乎是 Android Studio 3.6 的问题 - 请在此处查看问题:

This appears to be an issue with Android Studio 3.6 at the time of writing - see the issue here:

一种解决方法似乎是恢复到 Android Studio 3.5.

One workaround appears to be to revert to Android Studio 3.5.

或者手动添加资产似乎有效 - 以 ARCore 在线文档中的示例为例 (https://developers.google.com/ar/develop/java/sceneform):

Alternatively adding the asset manually appears to work - taking the example in the online documentation for ARCore (https://developers.google.com/ar/develop/java/sceneform):

按照以下步骤导入新的 3D 资产:

Follow these steps to import a new 3D asset:

  1. 验证您项目的 app 文件夹是否包含 sampledata 文件夹.

  1. Verify that your project's app folder contains a sampledata folder.

要创建文件夹,请右键单击项目"窗口中的应用程序文件夹,然后选择新建">示例数据目录".

To create the folder, right-click on the app folder in the Project window, then select New > Sample Data Directory.

sampledata 文件夹是您的 Android Studio 项目的一部分,但其内容不会包含在您的 APK 中.

The sampledata folder is part of your Android Studio project, but its contents will not be included in your APK.

复制您的 3D 模型源资产文件(*.obj、*.fbx 或 .gltf)及其所有依赖项(.mtl、*.bin、*.png、*.jpg 等)放入 sampledata 文件夹中.

Copy your 3D model source asset file (*.obj, *.fbx, or .gltf), and all of its dependencies (.mtl, *.bin, *.png, *.jpg, etc.) into the sampledata folder.

请勿将这些源文件复制到您项目的 assets 或 res 文件夹中,因为这会导致它们不必要地包含在您的 APK 中.

Do not copy these source files into your project's assets or res folder, as this will cause them to be included in your APK unnecessarily.

  1. 现在,不要按照上面链接中的说明进行右键单击并使用导入,而是手动将以下几行添加到 build.gradle(app) 文件的底部:

apply plugin: 'com.google.ar.sceneform.plugin'

sceneform.asset('sampledata/andy.obj', // 'Source Asset Path' specified during import.
        'default',                    // 'Material Path' specified during import.
        'sampledata/andy.sfa', // '.sfa Output Path' specified during import.
        'src/main/res/raw/andy')      // '.sfb Output Path' specified during import.

  1. 重新构建您的项目并正确导入可渲染文件 - 检查 andy.sfb 是否出现在res/raw"文件夹中以确保.

这篇关于Gradle 构建失败,新的导入规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆