3

Got this error after updating my Kotlin plugin on android studio.

package com.inovate.kotlin.module3.decorations

fun main(args: Array<String>) {
    makeDecorations()
}

fun makeDecorations() {
    val d1 = Decorations("rectangle", 56, 20)
}

data class Decorations(val shape : String, val weight : Int, val area : Int)

This is the error:

* Where:
Initialization script '/private/var/folders/bn/st769wd16nv1d5_wccw8_tm00000gn/T/DecorationsKt_main__2.gradle' line: 27

* What went wrong:
A problem occurred configuring project ': app'.
> Could not create task ':app:DecorationsKt.main()'.
   > SourceSet with name 'main' not found.

When I run a stack trace:

Caused by: org.gradle.api.internal.tasks.DefaultTaskContainer$TaskCreationException: Could not create task ':app:DecorationsKt.main()'.

Caused by: org.gradle.api.UnknownDomainObjectException: SourceSet with name 'main' not found.

I have updated all my dependencies, invalidated caches and restarted, and tried to delete my .idea folder but no luck.

jeanluc rotolo
  • 165
  • 1
  • 11

1 Answers1

0

This happens during file corrosion so some few steps to fix the issue

In intellij idea go to build > Step 1: clean project Step 2: Rebuild If it doesn't work Locate to project > delete .idea folder Finally invalidate cache restart

  • I have tried it and it still does not work :( – jeanluc rotolo Nov 30 '20 at 09:56
  • Ah, ok make sure you have deleted .idea folder after restart ide then the next step would be remove the last kotlin running configuration (alt + delete) in Run/Debug configuration finally run it from run gutter(icon in main function) if these steps won't work recreate new kotlin file(not a project) @jeanlucrotolo –  Nov 30 '20 at 10:10
  • Still did not work - I deleted the .idea folder, invalidate cache restart, removed the file from the kotlin running configuration then attempted to run from the gutter icon. Still no luck - I even created a new file and new project. – jeanluc rotolo Nov 30 '20 at 17:18
  • have you update your gradle @jeanlucrotolo –  Nov 30 '20 at 17:58
  • @jeanlucrotolo I mean gradle wrapper / gradle deamon –  Dec 02 '20 at 10:19
  • Yes I have updated the Gradle wrapper `buildToolsVersion "29.0.3"` – jeanluc rotolo Dec 03 '20 at 15:50
  • I have managed to get a temporary solution - https://stackoverflow.com/a/65129776/7952086 – jeanluc rotolo Dec 04 '20 at 15:04
  • Good to hear that –  Dec 05 '20 at 12:17