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

查看:101
本文介绍了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;)

我该如何解决?

推荐答案

-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.

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

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.

请勿将这些源文件复制到项目的资产或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天全站免登陆