Unknown property 'annotationProcessor' (Gradle 7.4)

I am trying to implement a Rooms database as part of a project in Android Studio. Gradle versions are the latest:
Android Gradle Plugin Version: 7.0.2
Gradle Version: 7.4

According to the tutorial (Android Room with a View - Java  |  Android Developers), one of the lines I need to add to my build.gradle (app) is the following:

    annotationProcessor "androidx.room:room-compiler:$rootProject.roomVersion"

However, when this line is included, I get the following build error:

Could not set unknown property 'annotationProcessor' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler:41

When this line is commented out, the app will compile, but not run.

From the research I’ve been doing, I feel like I’m missing something in my gradle configuration. But I’m a complete novice when it comes to gradle, and I’ve been banging my head against this problem for a couple hours now with no luck.

Any help is appreciated! If there is additional information I need to provide, please let me know.
Theresa

You say it instructs to add

annotationProcessor "androidx.room:room-compiler:$rootProject.roomVersion"

But that is not what you added.
You added

annotationProcessor = "androidx.room:room-compiler:$rootProject.roomVersion"

I knew it was something stupid! Thank you! I can’t believe how long my student and I stared at that and neither of us saw it.

The first is a method call (leaving out the parens is just syntactic sugar from Groovy).
The second is a property assignment.
The error says “could not set unknown property”.
:slight_smile:

Actually these things are one of the reasons I don’t use Groovy DSL anymore since Kotlin DSL became stable.
You have type-safe build scripts with amazing IDE support compared to Groovy.

Thanks, that’s good to know! I’ll make a note of that for the next time I teach Mobile Apps…year after next, which gives plenty of time for more things to change. : /