googlecodelabs / sceneform-intro

Other
25 stars 18 forks source link

Step 11 (importing models) does not work as documented when using Android Studio 3.6 #22

Open mr-z-ro opened 4 years ago

mr-z-ro commented 4 years ago

Following the instructions exactly leads to the following exception when using Android Studio 3.6:

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

There is a workaround noted a couple of days ago on StackOverflow which should at least be noted for those using the latest platform.

However that SO answer doesn't include the .fbx animation list. So while the community awaits an official fix, perhaps the instructions in this tutorial could also include a note for 3.6 users that they should update their build.gradle (app) to include the following lines at the end:

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

sceneform.asset('sampledata/models/andy_dance.fbx', // 'Source Asset Path' specified during import.
        'default',                    // 'Material Path' specified during import.
        'sampledata/models/andy.sfa', // '.sfa Output Path' specified during import.
        'src/main/res/raw/andy',  // '.sfb Output Path' specified during import (do not include extension)
        ['sampledata/models/andy_dance.fbx']) // List of Animation Path Strings
mr-z-ro commented 4 years ago

Seems also worth noting that the build process fails when capital letters are used for the sfa/sfb filenames. This is not immediately clear, as caps are used for some of the sampledata filenames like Cabin.obj.

After making all filenames all lowercase, a complete, functional config (in the app build.gradle) for the model imports follows:

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

sceneform.asset('sampledata/models/andy_dance.fbx', // 'Source Asset Path' specified during import.
        'default',                    // 'Material Path' specified during import.
        'sampledata/models/andy_dance.sfa', // '.sfa Output Path' specified during import.
        'src/main/res/raw/andy_dance',  // '.sfb Output Path' specified during import.
        ['sampledata/models/andy_dance.fbx']) // List of Animation Path Strings

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

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

sceneform.asset('sampledata/models/igloo.obj', // 'Source Asset Path' specified during import.
        'default',                    // 'Material Path' specified during import.
        'sampledata/models/igloo.sfa', // '.sfa Output Path' specified during import.
        'src/main/res/raw/igloo') // '.sfb Output Path' specified during import.
mr-z-ro commented 4 years ago

Also, it took me a while to realize the Uri.parse call at the beginning of Step 13 is for the assets folder, as referenced here: https://developers.google.com/ar/develop/java/sceneform/import-assets#create_the_renderable

However this workaround for step 11 renders to the res/raw folder instead.