简体   繁体   中英

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. I want to include this in a project set up with react-native init PROJECT . Following this straightforward guide from Google I add this to my gradle s:

The root build.gradle lists the Sceneform plugin dependency:

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:

…
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

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.

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

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. Older Android SDK versions rely on Java 7 while newer use Java 8.

Follow the steps here to set up your app properly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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