Good Morning everyone. Can I please ask for assist...
# community-support
s
Good Morning everyone. Can I please ask for assistance? I am trying to to run my app however, I am having trouble with gradle.
I keep getting this: FAILURE: Build failed with an exception. * Where: Build file 'C:\Users\sunny\OneDrive\Desktop\books\android\build.gradle' line: 11 * What went wrong: A problem occurred evaluating root project 'android'.
Could not find method implementation() for arguments [org.jetbrains.kotlinkotlin stdlib2.0.20] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
* Try:
Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.
Get more help at https://help.gradle.org.
BUILD FAILED in 1m 33s Error: Gradle task assembleDebug failed with exit code 1
I have tried all night to fix it but I have no idea what I am doing wrong now.
a
hi, it's hard to tell without the code that's failing, but it looks like you're trying to add a dependency on Kotlin stdlib? Can you share the code from the build.gradle, in particular on line 11?
but typically you shouldn't need to manually add a dependency on Kotlin stdlib, if you're using the Kotlin Gradle Plugin. It gets added automatically. Maybe you can just remove the dependency?
v
While what Adam said about the stdlib being added automatically, the source of your problem is quite clear. You try to add a dependency to the
implementation
configuration, but you do not have any plugin applied that adds such a configuration like the Kotlin plugin, the Java plugin, one of the Android plugins, and so on. As the error says it is happening on the root project called
android
, and the typical setup you would copy from a book like your path suggests is to have an empty root project and a sub project called
app
where you have your actual code, you would have applied the relevant plugins in the sub project and thus also need to add the dependency there. Besides that, I highly recommend to use Kotlin DSL instead of Groovy DSL. By now it is the default DSL, you immediately get type-safe build scripts, actual helpful error messages when mess up the syntax, and amazingly better IDE support if you use a good IDE like IntelliJ IDEA or Android Studio. Also, be very critic on anything you read in a book about Gradle, especially if it has a certain age. Gradle is still evolving relatively quickly and things that were good practice or state of the art some time ago, are now discouraged bad practices. Hence you often find stale or bad advice online or in older books.