简体   繁体   English

将SceneForm / ARCore添加到Gradle时,Android App无法编译

[英]Android App does not compile when SceneForm/ARCore added to Gradle

I am trying to set up a very basic ARCore application with Sceneform running. 我正在尝试使用Sceneform运行一个非常基本的ARCore应用程序。 I want to include this in a project set up with react-native init PROJECT . 我想将此包含在使用react-native init PROJECT设置的react-native init PROJECT Following this straightforward guide from Google I add this to my gradle s: 遵循Google这份简单明了的指南 ,我将其添加到了gradle

The root build.gradle lists the Sceneform plugin dependency: 根目录build.gradle列出了Sceneform插件依赖项:

buildscript {
  …
  dependencies {
    …
    classpath 'com.google.ar.sceneform:plugin:1.3.0'
  }
}

The app build.gradle includes two Sceneform dependencies, applies the plugin and includes a rule for converting the sampledata assets into a resource that is packaged with your app, and that Sceneform can load at runtime: 应用程序build.gradle包含两个Sceneform依赖项,应用了插件并包含了一个规则,用于将sampledata资产转换为与应用程序一起打包的资源,并且Sceneform可以在运行时加载:

…
dependencies {
  …
  implementation 'com.google.ar.sceneform:core:1.3.0'
  implementation 'com.google.ar.sceneform.ux:sceneform-ux:1.3.0'
}

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

My root build.gradle now looks the following 我的root build.gradle现在看起来如下

dependencies {
    classpath 'com.android.tools.build:gradle:3.1.3'
    classpath 'com.google.ar.sceneform:plugin:1.3.0'

while my apps build.gradle looks like this. 而我的应用程序build.gradle看起来像这样。

dependencies {
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
    compile "com.facebook.react:react-native:+"  // From node_modules
    implementation 'com.google.ar.sceneform:core:1.3.0'
    implementation 'com.google.ar.sceneform.ux:sceneform-ux:1.3.0'

} }

When I am trying to compile, I get: 当我尝试编译时,我得到:

com.android.build.api.transform.TransformException: com.android.builder.dexing.DexArchiveBuilderException: com.android.builder.dexing.DexArchiveBuilderException: Failed to process /Users/.../.gradle/caches/transforms-1/files-1.1/sceneform-ux-1.3.0.aar/32c1e2ae4c703fa551b4355de5a8e899/jars/classes.jar com.android.build.api.transform.TransformException:com.android.builder.dexing.DexArchiveBuilderException:com.android.builder.dexing.DexArchiveBuilderException:无法处理/Users/.../.gradle/caches/transforms-1 /files-1.1/sceneform-ux-1.3.0.aar/32c1e2ae4c703fa551b4355de5a8e899/jars/classes.jar

I tried to clean the Project as well as adding these lines 我试图清理项目以及添加这些行

defaultConfig {
    multiDexEnabled true
}

and have the same result. 并具有相同的结果。

Alright, apparently the problem arises with Java 8 language features and new/old Android SDK versions. 好吧,显然问题出在Java 8语言功能和新旧Android SDK版本上。 Older Android SDK versions rely on Java 7 while newer use Java 8. 较旧的Android SDK版本依赖Java 7,而较新的版本则使用Java 8。

Follow the steps here to set up your app properly. 请按照此处的步骤正确设置您的应用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM