无法访问类“java.lang.String”。检查模块类路径是否缺少或冲突的依赖项

Sur*_*rma 5 java android gradle kotlin

我正在为我的 android 项目设置一个 java/kotlin 库,其中我使用 moshi 转换器创建一个数据类(模型)。但问题是注释@JsonClass,在其他地方我收到此错误

无法访问类“java.lang.String”。检查模块类路径是否缺少或冲突的依赖项

数据类

数据类图像

IDE显示的错误

库的gradle代码

plugins {
    id 'java-library'
    id 'kotlin'
    id 'kotlin-kapt'
}

java {
    sourceCompatibility = JavaVersion.VERSION_11
    targetCompatibility = JavaVersion.VERSION_11
}
dependencies {

    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation "com.squareup.retrofit2:retrofit:2.9.0"
    implementation "com.squareup.retrofit2:converter-moshi:2.9.0"
    implementation "com.squareup.moshi:moshi:1.12.0"
    kapt "com.squareup.moshi:moshi-kotlin-codegen:1.12.0"
} 
Run Code Online (Sandbox Code Playgroud)

以及应用程序级别的 build.gradle 文件

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    ext {
        compose_version = '1.1.0-alpha01'
        kotlin_version = '1.5.21'
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:7.0.0"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)

应用程序级别的gradle代码

plugins {
    id 'com.android.application'
    id 'kotlin-android'
}

android {
    compileSdk 30
    buildToolsVersion "30.0.3"

    defaultConfig {
        applicationId "com.example.composeappname"
        minSdk 23
        targetSdk 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.tests.runner.AndroidJUnitRunner"
        vectorDrawables {
            useSupportLibrary true
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_11
        targetCompatibility JavaVersion.VERSION_11
    }
    kotlinOptions {
        jvmTarget = '1.8'
        useIR = true
    }
    buildFeatures {
        compose true
    }
    composeOptions {
        kotlinCompilerExtensionVersion compose_version
        kotlinCompilerVersion '1.4.32'
    }
}

dependencies {

    implementation 'androidx.core:core-ktx:1.6.0'
    implementation 'androidx.appcompat:appcompat:1.3.1'
    implementation 'com.google.android.material:material:1.4.0'
    implementation "androidx.compose.ui:ui:$compose_version"
    implementation "androidx.compose.material:material:$compose_version"
    implementation "androidx.compose.ui:ui-tooling:$compose_version"
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
    implementation 'androidx.activity:activity-compose:1.3.1'

    implementation project(":libmynetworklibrary")
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.tests.ext:junit:1.1.3'
    androidTestImplementation 'androidx.tests.espresso:espresso-core:3.4.0'
    androidTestImplementation "androidx.compose.ui:ui-tests-junit4:$compose_version"
}
Run Code Online (Sandbox Code Playgroud)