Gradle exclude R.java in Android Javadocs when internal classes depend on R.java Gradle exclude R.java in Android Javadocs when internal classes depend on R.java android android

Gradle exclude R.java in Android Javadocs when internal classes depend on R.java


On Android Studio, go to the following settings (settings can be accessed via File > Settings):

Appearance & Behaviour > Scopes

You should be able to browse your project files here. Now select your files and use the buttons on the far right to include/exclude them to your scope (you can exclude, or not include R.java files and BuildConfig.java files). Make sure the checkbox at the bottom "Share scope" is ticked, and your scope has a memorable name.

Next go to the Javadoc generator dialog (Tools > Generate Javadoc). Select the bottom radio button ("Custom Scope") and then from the menu, select the scope you created earlier. There are other settings you can configure for your Javadocs.

Finally click 'OK', and you should have generated Javadocs.

Hopefully this should solve your problem.


I suspect you are trying to exclude R.java because the auto-generated javadoc in that class doesn't conform to doclint. So you are seeing a bunch of errors and warnings like:

R.java:530: error: unknown tag: colgroup     * <colgroup align="left" />       ^

What about removing the exclude '**/R.java' and suppressing any errors generated by R.java instead?

Using this as a basis, and then looking at Xdoclint documentation, you should be able suppress R.java errors by adding:

options.addStringOption('Xdoclint:none R.java', '-quiet')

I have tested this and it removes the R.java errors. You'll still see them print to console, but it won't count in the final error numbers.