10

I have two projects in Android studio: model and app.
model is written completely in java, graddle file starts with apply plugin: 'java'
app is written in android-java and depends on model. The graddle file starts with apply plugin: 'com.android.application'

I can insert this snippet:

/**
 * Debugging
 *
 * @throws IllegalArgumentException
 *             if illegal == true
 */
private void debug(boolean illegal){
    if (illegal)
        throw new IllegalArgumentException("tu");
}

anywhere in app and there are no errors. However when I insert it anywhere in model I get an error: Symbol 'IllegalArgumentException' is inaccessible from here and upon clicking 'more'
Inspection info: This inspection points out unresolved references inside javadoc
I can however compile, run without problems.

My Android-studio version is 3.4. I do not remember having this problem with the version I used before but I'm not sure which version that was.

peer
  • 4,171
  • 8
  • 42
  • 73
  • I get it too; on a code base that did not have that before. I don't get it! I will say the error is in the javadoc @throws .. – Brian Reinhold May 24 '19 at 14:43
  • Did you try checking the box Declaration has javadoc – Manoj Perumarath Jun 13 '19 at 11:17
  • @ManojPerumarath Thanks for the hint! `[shift] [shift] declaration javadoc` offers a switch for 'Javadoc: Declaration has problems in Javadoc references'. When I switch it off, the error goes away. But that's just suppressing the error message, right? How do I correctly specify an IllegalArgumentException? – peer Jun 13 '19 at 11:24
  • Did you try running the project again, are you facing the same issue again – Manoj Perumarath Jun 13 '19 at 11:29
  • 1
    @ManojPerumarath When I uncheck the box 'Javadoc: Declaration has problems in Javadoc references' the error messages are gone, I don't even need to run the project again. But I'm confused: I've aways written throws declarations in the javadoc like that. Am I doing javadoc wrong? As I understand unchecking the box just makes that the error message is no longer displayed. But what is the point of the error message? What would be correct javadoc if I didn't want to uncheck the box? – peer Jun 13 '19 at 12:36
  • I'm having the same issues, it must be a bug in the latest version of AS, right? – mhswtf Jun 18 '19 at 09:44

1 Answers1

7

I believe there is nothing wrong with your code. I can see the same error in my project. There is a bug in Android Studio (IntelliJ Idea), an issue has already been created: Javadoc inspection "Declaration has problems in Javadoc reference" wrongly marks types as inaccessible. So the only option is either switching off the check, or ignoring the error unless you suffer from OCD.

Miloš Černilovský
  • 3,846
  • 1
  • 28
  • 30