I'm attempting to retrieve a list of classes with a specific annotation in Android. I'm trying to use the Reflections library to do so. But no matter what I do, Reflections returns an empty set. Finally, I tried using Reflections.getAllTypes(), which should return all classes in a package, and it gives me the message "Couldn't find subtypes of Object. Make sure SubTypesScanner initialized to include Object class - new SubTypesScanner(false)" I have verified that I am doing so, so I looked in the code for that method and it returns that error if there are no classes in the package.
Here's an example of the code where I'm getting the error:
Reflections reflections = new Reflections(this.getClass().getPackage().getName(),
new SubTypesScanner(false));
Set<String> classes = reflections.getAllTypes(); // Throws runtime error
This should, at the very least, return the class that it is called from. I've also tried using an empty string for the package, and the answer here. Any ideas what could be causing this?
Aucun commentaire:
Enregistrer un commentaire