Labros Marados
Labros Marados

Reputation: 61

Gradle build error on run-time (Realm DB, android, kotlin)

I am implementing an application with android studio and Realm DataBase, however i am getting a cryptic error message from gradle console when i run the project: My build.gradle file includes the following plugins:

plugins {
    apply plugin: 'com.android.application'
    apply plugin: 'kotlin-kapt'
    apply plugin: 'kotlin-android'
    apply plugin: 'kotlin-android-extensions'
    apply plugin: 'realm-android'
}

Exception is the following :

2020-11-25T15:47:14.576+0200 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':app'. 2020-11-25T15:47:14.576+0200 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.configuration.project.LifecycleProjectEvaluator.wrapException(LifecycleProjectEvaluator.java:75) Caused by: java.lang.ClassCastException: org.codehaus.groovy.ast.expr.TupleExpression cannot be cast to org.codehaus.groovy.ast.expr.ArgumentListExpression

What can be the culprit behind this error? I do not getting other errors on the project files, or through code analysis.

Upvotes: 0

Views: 334

Answers (2)

Cassiano Junior
Cassiano Junior

Reputation: 11

You can try:

plugins {
   id: 'com.android.application'
   id: 'kotlin-kapt'
   id: 'kotlin-android'
   id: 'kotlin-android-extensions'
   id: 'realm-android'
}

insted of

plugins{
   apply plugin: 'kotlin-kapt'
}

This happens because when you using a list of plugins, the correct syntax is just putting id 'name-of-plugin'. Use the "apply plugin" only when you adding outside of the list.

Upvotes: 0

Rob Evans
Rob Evans

Reputation: 2874

Try:

plugins {
    id: 'com.android.application'
    id: 'kotlin-kapt'
    id: 'kotlin-android'
    id: 'kotlin-android-extensions'
    id: 'realm-android'
}

Seems like the error :

...TupleExpression cannot be cast to org.codehaus.groovy.ast.expr.ArgumentListExpression

is telling you it cannot parse the list of plugins - probably because the format isn't as expected

Upvotes: 1

Related Questions