I want to access a resource from my andoid studio project in my annotation processor.
I first tried to use the getResource method from filer:
FileObject fo = processingEnv.getFiler().getResource(StandardLocation.SOURCE_PATH, "", "src/main/res/layout/activity_main.xml");
, but it always throwed a exception that just returned "src/main/res/layout/activity_main.xml" as a message.
Next think i have tried was
this.getClass().getResource("src/main/res/layout/activity_main.xml")
, but this always returned null.
The last think i have tried to use was this:
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null);
Iterable<? extends File> locations = fm.getLocation(StandardLocation.SOURCE_PATH);
for (File file : locations) {
System.out.print(file.getAbsolutePath());
}
, but it throwes a null pointer exception