Using Android Studio and creating a java library module as part of a sub project I get an error on the following java statement:
javaFile.writeTo(System.out);
and it complains of can not resolve symbol 'writeTo' and unknown class 'System.out'.
Here's the gist of the source code class
import com.squareup.javapoet.JavaFile;
import com.squareup.javapoet.MethodSpec;
import com.squareup.javapoet.TypeSpec;
import javax.lang.model.element.Modifier;
public class MyClass {
...
JavaFile javaFile = JavaFile.builder("com.foobar.helloworld", helloWorld)
.build();
javaFile.writeTo(System.out);
}
A bit hard to say without knowing exactly what your exception was, but I had something similar pop up when I was testing out a sub-module annotation processor. When linking the processor to my main module, I was getting a
java.lang.NoClassDefFoundError: com/squareup/javapoet/MethodSpec
. I was using android-apt to get the annotation processor working, so in mybuild.config
my dependencies had the apt configuration definition:Once i included the above noted dependency, then all worked fine. Not sure if this applies to your situation without more details, but this got me back on track.