For Android applications I write java library. In Android Studio, the library is created as a java library module.
The problem arose when debugging this library. Breakpoints in it do not work. Naturally, the Log function from android.util cannot be applied there, since library java.
Please tell me how for java library module do debugging in Android Studio?
================================================= =====
I will clarify my question, maybe I have no ordinary problem. How to debug class generating code using AbstractProcessor
Here is the code itself:
@SupportedAnnotationTypes("com.bignerdranch.android.annotproc.processor.CustomAnnotation") @SupportedSourceVersion(SourceVersion.RELEASE_7) public class CustomAnnotationProcessor extends AbstractProcessor { @Override public synchronized void init(ProcessingEnvironment processingEnvironment) { super.init(processingEnvironment); } @Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { StringBuilder builder = new StringBuilder() .append("package com.bignerdranch.android.annotproc.generated;\n\n") .append("public class GeneratedClass {\n\n") // open class .append("\tpublic String getMessage() {\n") // open method .append("\t\treturn \""); // for each javax.lang.model.element.Element annotated with the CustomAnnotation for (Element element : roundEnv.getElementsAnnotatedWith(CustomAnnotation.class)) { String objectType = element.getSimpleName().toString(); // this is appending to the return statement builder.append(objectType).append(" says hello!\\n"); } builder.append("\";\n") // end return .append("\t}\n") // close method .append("}\n"); // close class try { // write the file JavaFileObject source = processingEnv.getFiler().createSourceFile("com.bignerdranch.android.annotproc.generated.GeneratedClass"); Writer writer = source.openWriter(); writer.write(builder.toString()); writer.flush(); writer.close(); } catch (IOException e) { // Note: calling e.printStackTrace() will print IO errors // that occur from the file already existing after its first run, this is normal } return true; } } The code is generated normally. But when I put a breakpoint for example in the line
StringBuilder builder = new StringBuilder() .append("package com.bignerdranch.android.annotproc.generated;\n\n") .append("public class GeneratedClass {\n\n") // open class .append("\tpublic String getMessage() {\n") // open method .append("\t\treturn \""); or on any other line in this class, nothing happens, there is no stopping. How to debug such code?
Thank.