3

Created a new android project then I have added a new module to it. The idea is to separate all my network calls and serialization to a separate module.

module was created by right click on project > new > module > Java or Kotlin Library. This added a new module, but all the extensions functions that work on Strings show error:

Cannot access 'java.io.Serializable' which is a supertype of 'kotlin.String'. Check your module classpath for missing or conflicting dependencies

my new module build.gradle is:

plugins {
    id 'java-library'
    id 'kotlin'
    id 'org.jetbrains.kotlin.plugin.serialization' version '1.5.31'
}

java {
    sourceCompatibility = JavaVersion.VERSION_1_8
    targetCompatibility = JavaVersion.VERSION_1_8
}

dependencies {
    implementation("com.squareup.okhttp3:okhttp:5.0.0-alpha.2")
    implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.0")
    implementation("com.squareup.okhttp3:logging-interceptor:4.9.2")
    testImplementation 'junit:junit:4.13.2'
}

and a single class, which has errors:

package com.example.lib

import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.RequestBody.Companion.toRequestBody

class MyClass {
    private val client = OkHttpClient()

    fun makeRequest() {
        val randomVariable = "lowercase letters".uppercase()

        val request = Request.Builder()
            .get()
            .url("https://stackoverflow.com/")
            .build()

        val response = client.newCall(request).execute().body?.string()!!
    }
}

enter image description here

I have tried to invalidate cache, clean .gradle cache, reboot, used Java 8 and Java 11 for Gradle JDK but did not work...

1
  • 1
    I have the same issue Commented Jan 22, 2022 at 15:01

1 Answer 1

1

Deleting ~/Library/Application Support/Google/AndroidStudioPreview20XX.X/options/jdk.table.xml file fixes this problem.

Also here is the issue for this https://issuetracker.google.com/issues/213131387

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.