Java Community | Help. Code. Learn.JC|HCL
Java Community | Help. Code. Learn.โ€ข2y agoโ€ข
5 replies
Asdru

Gson cannot be resolved to a type error randomly started appearing

public static Partita carica(int id) {
        Gson gson = new Gson();
        return gson.fromJson(Utili.leggiFileJson("partite", Integer.toString(id)), Partita.class);
    }

i have this method that loads a json file into a class, which i dont exactly know it started throwing an error at this line
Gson gson = new Gson();
despite me not touching that function or the Util function. The wierd part is that if i rewrite that function in a runnable class like
public static void main(String[] args) {
                Gson gson = new Gson();
                Partita p = gson.fromJson(Utili.leggiFileJson("partite", Integer.toString(25066)), Partita.class);
        }

it works. so i can say its not an issue with imports or my util function
Was this page helpful?