任务 :app:kaptDebugKotlin FAILED(错误:找不到符号)- Kotlin

时间:2021-07-29 06:34:40

标签: java android kotlin build compiler-errors

我每次尝试运行应用程序时都会收到此错误

enter image description here

build.gradle(project):

buildscript {
ext.kotlin_version = "1.4.31"
ext.nav_version = "2.3.0"
ext.groupie_version = "2.3.0"
ext.hilt_version = '2.28-alpha'
ext.coroutines_version = "1.3.7"
ext.gradle_version = '4.0.2'
repositories {
    google()
    jcenter()

}
dependencies {
    classpath "com.android.tools.build:gradle:4.1.3"

    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    def nav_version = "2.3.4"
    classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
    classpath 'com.google.gms:google-services:4.3.8'
    classpath "com.google.dagger:hilt-android-gradle-plugin:$hilt_version"
    classpath 'com.google.firebase:firebase-crashlytics-gradle:2.7.0'

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

allprojects {
repositories {
    google()
    jcenter()
    mavenCentral()
    maven { url 'https://maven.google.com' }
    maven { url 'https://jitpack.io' }
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

build.gradle(模块):

plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
id 'kotlin-android'
id 'kotlin-kapt'
//id 'kotlin-android-extensions'
id "androidx.navigation.safeargs.kotlin"
id 'dagger.hilt.android.plugin'
id 'com.google.firebase.crashlytics'
id 'kotlin-parcelize'
}

android {
compileSdkVersion 30
buildToolsVersion "30.0.3"

sourceSets {
    main.java.srcDirs += 'src/main/kotlin'
}

defaultConfig {

    applicationId "io.Qalby.app"
    minSdkVersion 23
    targetSdkVersion 30
    versionCode 1
    versionName "1.0"
    multiDexEnabled true
    buildConfigField("String", "API_TOKEN", API_TOKEN)
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}
buildFeatures{
    dataBinding = true
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
    coreLibraryDesugaringEnabled = true
}
kotlinOptions {
    jvmTarget = '1.8'
}
repositories {
    jcenter()
}
}

我尝试了近两天的很多解决方案,仍然遇到同样的问题..出了什么问题?

应用程序运行良好,但在我添加了一些文件后,我遇到了这个问题

我尝试重命名文件(可能是因为名称是“Zone”而导致此问题) 我试图改变 kotlin_version 但没有解决这个问题

根据要求,这里是 StateZone 文件:

import com.google.gson.annotations.SerializedName
data class StateZone (

@SerializedName("zone") val zone : String,
@SerializedName("start") val start : String,
@SerializedName("end") val end : String,
@SerializedName("locations") val locations : List<String>,
@SerializedName("prayer_times") val prayer_times : List<Prayer_times>
)

这里是 PrayersManager:

class PrayersManager
private constructor(
@ApplicationContext private val context: Context
) {
var con:Context
var settings:Settings
val praysNames:Array<String>
lateinit var locale: Locale
lateinit var geocoder: Geocoder
private val is24Format = DateFormat.is24HourFormat(context)
private val dispatcher = Dispatchers.IO
private lateinit var countDownTimer: CountDownTimer
val countDownPrayerTime: LiveData<String> = MutableLiveData()
val viewPrayersLive : LiveData<ArrayList<Pray>> = MutableLiveData()
val todayPrayersLive : LiveData<ArrayList<Pray>> = MutableLiveData()
val nextPrayLive: LiveData<Int> = MutableLiveData()
val countryName: LiveData<String> = MutableLiveData()
val stateName: LiveData<String> = MutableLiveData()

0 个答案:

没有答案