Invalid type in built-in function 'dict2inst'. Cannot convert argument 1 from Nil to Dictionary.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By EmanuelOzorio

I’m trying to load resources dynamically. It works normally on the computer, but on android the following error occurs:

Invalid type in built-in function ‘dict2inst’. Cannot convert argument 1 from Nil to Dictionary.

I’m trying to load some Curve2D exported earlier. Here is the code:

extends Node

var paths = []

const path_dir = "res://paths/"

func _ready():
    load_paths()
    pass

func random_path():
    return paths[randi() % paths.size()]

func load_paths():
    var dir = Directory.new()
    dir.change_dir(path_dir)
    dir.list_dir_begin()

    var path_file = dir.get_next()
    var path
    while path_file != "":
        if dir.current_is_dir():
            pass
        else:
            print("loading: " + path_dir + path_file)
            path = load(path_dir + path_file)
            if path && path is Curve2D: #error occours here
                paths.append(path)

        path_file = dir.get_next()