46

Have been facing this error after migrating to AndroidX.

java.lang.IllegalStateException: SimpleTypeImpl should not be created for error type: ErrorScope{Error scope for class <ERROR CLASS> with arguments: org.jetbrains.kotlin.types.IndexedParametersSubstitution@14ac19e7}

This link does not help much

Shahzeb
  • 3,696
  • 4
  • 28
  • 47
  • Make sure you updated all: IDE, Gradle, Kotlin version, Kotlin IDE plugin etc. I believe I had this once and it was IDE/plugin related. – shkschneider Jan 14 '19 at 15:24
  • I also see this! Were you able to resolve this? – Utkarsh Barsaiyan Jan 15 '19 at 20:23
  • @UtkarshBarsaiyan I had to make changes manually even after choosing Migrate to AndroidX from Android Studio and I have realised until everything is up to date(versions, IDE, gradle, code etc), this error wont go. – Shahzeb Jan 16 '19 at 02:21
  • 5
    I found that the next line after the `java.lang.IllegalStateException` line gives you the name of the problematic class. In my case, I didn't have the gradle dependency (for rxjava) in the offending library module. – AgileNinja Feb 15 '19 at 20:57
  • Have you got the solution? – Malwinder Singh Feb 25 '19 at 07:23
  • 2
    In addition to @AgileNinja's suggestion, my error was outputting `[ERROR: Response]`. It was because I had removed the retrofit dependency from one of my modules. Nice 2 hours wasted... – StuStirling Jun 11 '19 at 13:22

8 Answers8

37

For me, the error was appearing due to invalid import statement. Android Studio didn't show anything regarding the same. I had to go to every single file, then studio shown the invalid import error. Fixed it and the build error's gone.

theapache64
  • 10,926
  • 9
  • 65
  • 108
  • It actually showed in the preview of each file when searching for "import", which gave me more clues of what had gone wrong. – Rickard Elimää Aug 26 '19 at 12:54
  • 3
    It is indeed the missing imports are the caused on my side. Use the *Analyze > Inspect Code* menu if you don't want to go every single file checking the missing imports. – glagarto Dec 18 '19 at 20:01
  • 1
    For me, it was a similar problem. Also, the import was in a test file, which I've observed in the past that don't get a compiler check by the IDE until they are run or opened... – pablisco Aug 01 '20 at 16:51
  • 1
    Similar problem. Thank you for your experiences. – Georgiy Chebotarev Aug 03 '20 at 14:18
  • @pablisco you saved my day. My missing import statement was indeed located in a test file – Cris Aug 05 '20 at 11:57
18

I updated to Kotlin 1.3.20 but it still did not work. Then I decided to check the Kotlin source code. I found this link

I had an interface called DisplayItem<T> and I removed its type parameter. After this, I started to get the error. Actually, at the end of the error in logcat it says DisplayItem

So i checked all DisplayItem types in code and I found I forgat to remove one type parameter in a LiveData variable like the follwoing:

MediatorLiveData<DataHolder<List<DisplayItem<MessageViewEntity>>>>

After removing type parameter from the variable it started to compile. I hope this'll help you.

Note: You can use git grep for a quick search.

savepopulation
  • 11,736
  • 4
  • 55
  • 80
9

My main tip to solve this issue would be when you're just getting the error message with no clue where the real error is, try the Android studio Analyze/Inspect code option. Digging through the output from this I found the actual compile errors that were triggering the problem and then could easily fix them.

The actual problem in my case was when changing a generic class, that had a nested class, into an abstract class and creating two sub-classes to replace it's previous usage. I still had references my code to the original abstract base class where I should have replaced them with one of the two new sub-classes.

greatape
  • 324
  • 3
  • 5
4

Migrate to AndroidX option in Android Studio didn't help much. I solved this error by making changes in every file manually, changed the package names according to AndroidX in both code and xml. If any file is left unchanged, you will see this error. Please make sure your Kotlin plugin version, gradle plugin version, build tools and Android studio version is up to date.

Shahzeb
  • 3,696
  • 4
  • 28
  • 47
4

I did following steps to solve the issue.

1-Updated android studio from 4.1.1 to 4.2.1

2-Update below line in gradle-warepper.properties file

distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-all.zip

3- Update some kotlin extentions like below

buildscript {
    ext.kotlin_version = '1.3.72'

to

buildscript {
    ext.kotlin_version = '1.4.32'

 dependencies {
        classpath 'com.android.tools.build:gradle:4.0.1'

to

dependencies {
        classpath 'com.android.tools.build:gradle:4.2.1'

It will take some time for gradle sync etc but finnaly for me solved the problem after waisting whole day.

Ejaz Ahmad
  • 614
  • 5
  • 12
3

I just updated my kotlin-gradle-plugin version in root build.gradle and it resolved my issue

classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.72"

to

classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.32"
Nihas Nizar
  • 619
  • 8
  • 15
1

Upgrade your Kotlin dependency to 1.7.20 and the compiler will highlight the source of your issues.

IgorGanapolsky
  • 26,189
  • 23
  • 116
  • 147
kassim
  • 3,880
  • 3
  • 26
  • 27
1

If this error is related to import. So we can also do this

Right click on module -> Optimise Imports.

In this way we can save time from going to every single file and findout that import.

Fahd Tahir
  • 55
  • 5