nowinandroid: [Bug]: Can't Build the Project

Is there an existing issue for this?

  • I have searched the existing issues

Is there a StackOverflow question about this issue?

  • I have searched StackOverflow

What happened?

I can’t build the project. I’m on Android Studio Electric Eel, Gradle 7.4, Using Java 11. The build keeps failing with the following output

Relevant logcat output

> Task :build-logic:convention:compileKotlin
e: /Users/isaac/AndroidStudioProjects/nowinandroid/build-logic/convention/src/main/kotlin/nowinandroid.android.application.compose.gradle.kts: (23, 1): Expression 'android' cannot be invoked as a function. The function 'invoke()' is not found
e: /Users/isaac/AndroidStudioProjects/nowinandroid/build-logic/convention/src/main/kotlin/nowinandroid.android.application.compose.gradle.kts: (23, 1): Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: 
internal val ComPluginGroup.android: ComAndroidPluginGroup defined in gradle.kotlin.dsl.plugins._575eff10af4d8ac420c2c0a93a3cb44b in file PluginSpecBuilders.kt
internal val OrgJetbrainsKotlinPlatformPluginGroup.android: PluginDependencySpec defined in gradle.kotlin.dsl.plugins._575eff10af4d8ac420c2c0a93a3cb44b in file PluginSpecBuilders.kt
internal val OrgJetbrainsKotlinPluginGroup.android: PluginDependencySpec defined in gradle.kotlin.dsl.plugins._575eff10af4d8ac420c2c0a93a3cb44b in file PluginSpecBuilders.kt
internal val PluginDependenciesSpec.android: PluginDependencySpec defined in gradle.kotlin.dsl.plugins._575eff10af4d8ac420c2c0a93a3cb44b in file PluginSpecBuilders.kt
e: /Users/isaac/AndroidStudioProjects/nowinandroid/build-logic/convention/src/main/kotlin/nowinandroid.android.application.compose.gradle.kts: (24, 29): Type mismatch: inferred type is Nowinandroid_android_application_compose_gradle but CommonExtension<*, *, *, *> was expected
e: /Users/isaac/AndroidStudioProjects/nowinandroid/build-logic/convention/src/main/kotlin/nowinandroid.android.application.gradle.kts: (24, 1): Expression 'android' cannot be invoked as a function. The function 'invoke()' is not found
e: /Users/isaac/AndroidStudioProjects/nowinandroid/build-logic/convention/src/main/kotlin/nowinandroid.android.application.gradle.kts: (24, 1): Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: 
internal val ComPluginGroup.android: ComAndroidPluginGroup defined in gradle.kotlin.dsl.plugins._575eff10af4d8ac420c2c0a93a3cb44b in file PluginSpecBuilders.kt
internal val OrgJetbrainsKotlinPlatformPluginGroup.android: PluginDependencySpec defined in gradle.kotlin.dsl.plugins._575eff10af4d8ac420c2c0a93a3cb44b in file PluginSpecBuilders.kt
internal val OrgJetbrainsKotlinPluginGroup.android: PluginDependencySpec defined in gradle.kotlin.dsl.plugins._575eff10af4d8ac420c2c0a93a3cb44b in file PluginSpecBuilders.kt
internal val PluginDependenciesSpec.android: PluginDependencySpec defined in gradle.kotlin.dsl.plugins._575eff10af4d8ac420c2c0a93a3cb44b in file PluginSpecBuilders.kt
e: /Users/isaac/AndroidStudioProjects/nowinandroid/build-logic/convention/src/main/kotlin/nowinandroid.android.application.gradle.kts: (25, 28): Type mismatch: inferred type is Nowinandroid_android_application_gradle but CommonExtension<*, *, *, *> was expected
e: /Users/isaac/AndroidStudioProjects/nowinandroid/build-logic/convention/src/main/kotlin/nowinandroid.android.application.gradle.kts: (27, 5): Unresolved reference: defaultConfig
e: /Users/isaac/AndroidStudioProjects/nowinandroid/build-logic/convention/src/main/kotlin/nowinandroid.android.application.gradle.kts: (28, 9): Unresolved reference: targetSdk
e: /Users/isaac/AndroidStudioProjects/nowinandroid/build-logic/convention/src/main/kotlin/nowinandroid.android.application.jacoco.gradle.kts: (24, 1): Expression 'android' cannot be invoked as a function. The function 'invoke()' is not found
e: /Users/isaac/AndroidStudioProjects/nowinandroid/build-logic/convention/src/main/kotlin/nowinandroid.android.application.jacoco.gradle.kts: (24, 1): Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: 
internal val ComPluginGroup.android: ComAndroidPluginGroup defined in gradle.kotlin.dsl.plugins._575eff10af4d8ac420c2c0a93a3cb44b in file PluginSpecBuilders.kt
internal val OrgJetbrainsKotlinPlatformPluginGroup.android: PluginDependencySpec defined in gradle.kotlin.dsl.plugins._575eff10af4d8ac420c2c0a93a3cb44b in file PluginSpecBuilders.kt
internal val OrgJetbrainsKotlinPluginGroup.android: PluginDependencySpec defined in gradle.kotlin.dsl.plugins._575eff10af4d8ac420c2c0a93a3cb44b in file PluginSpecBuilders.kt
internal val PluginDependenciesSpec.android: PluginDependencySpec defined in gradle.kotlin.dsl.plugins._575eff10af4d8ac420c2c0a93a3cb44b in file PluginSpecBuilders.kt
e: /Users/isaac/AndroidStudioProjects/nowinandroid/build-logic/convention/src/main/kotlin/nowinandroid.android.application.jacoco.gradle.kts: (25, 5): Unresolved reference: androidComponents
e: /Users/isaac/AndroidStudioProjects/nowinandroid/build-logic/convention/src/main/kotlin/nowinandroid.android.application.jacoco.gradle.kts: (26, 25): Type mismatch: inferred type is Nowinandroid_android_application_jacoco_gradle but AndroidComponentsExtension<*, *, *> was expected
e: /Users/isaac/AndroidStudioProjects/nowinandroid/build-logic/convention/src/main/kotlin/nowinandroid.android.library.compose.gradle.kts: (23, 1): Expression 'android' cannot be invoked as a function. The function 'invoke()' is not found
e: /Users/isaac/AndroidStudioProjects/nowinandroid/build-logic/convention/src/main/kotlin/nowinandroid.android.library.compose.gradle.kts: (23, 1): Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: 
internal val ComPluginGroup.android: ComAndroidPluginGroup defined in gradle.kotlin.dsl.plugins._575eff10af4d8ac420c2c0a93a3cb44b in file PluginSpecBuilders.kt
internal val OrgJetbrainsKotlinPlatformPluginGroup.android: PluginDependencySpec defined in gradle.kotlin.dsl.plugins._575eff10af4d8ac420c2c0a93a3cb44b in file PluginSpecBuilders.kt
internal val OrgJetbrainsKotlinPluginGroup.android: PluginDependencySpec defined in gradle.kotlin.dsl.plugins._575eff10af4d8ac420c2c0a93a3cb44b in file PluginSpecBuilders.kt
internal val PluginDependenciesSpec.android: PluginDependencySpec defined in gradle.kotlin.dsl.plugins._575eff10af4d8ac420c2c0a93a3cb44b in file PluginSpecBuilders.kt

Code of Conduct

  • I agree to follow this project’s Code of Conduct

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 16
  • Comments: 37 (12 by maintainers)

Most upvoted comments

@Zikstar , I got the same problem & fixed it by upgrading the GradlePlugin from 7.1.2 to 7.1.3

Weird, what just helped me is to add an empty line to root build.gradle.kts

Changing AGP version to 7.1.3 didn’t help me.

For anyone facing this problem in the future, upgrade “androidGradlePlugin” in the file libs.versions.toml from 7.1.2 to 7.1.3 or later. This makes sense because AGP 7.1.2 is not compatible with Gradle 7.4 which this project specifies in its gradle-wrapper.properties. See https://developer.android.com/studio/releases/gradle-plugin#updating-gradle for compatible versions of AGP and Gradle.

Yes it worked, but now I getting another error :

Settings file ‘/Users/shashank.kapsime/StudioProjects/nowinandroid/build-logic/settings.gradle.kts’ line: 25

Using dependency catalogs requires the activation of the matching feature preview. See the documentation at https://docs.gradle.org/7.1/userguide/platforms.html#sub:central-declaration-of-dependencies

#38 was just merged, which should also help in this area. Please let us know if you’re still running into this issue on the latest main branch after the updates!

For everyone who survive with gradle build issue:

  • Change the androidGradlePlugin = “7.1.3” > Build again
  • If not then change JDK from 1.8 to 11

change jdk 11 but not work 😭

I changed jdk 11 (Embedded SDK). I could build.

Thank you 🙇

changing the androidGradlePlugin to 7.1.3 and rm $project/.gradle/ & rm $project build-logic/.gradle/

For me also changing the androidGradlePlugin to 7.1.3 resolved the issues.