Android Studio Kotlin 编译器错误 node.sym 不能为空

R.C*_*der 14 android gradle kotlin android-studio build.gradle

突然,我的 android studio gradle 构建失败,出现未知错误:

java.lang.IllegalStateException: failed to analyze: com.sun.tools.javac.util.ClientCodeException: java.lang.IllegalStateException: node.sym must not be null
Run Code Online (Sandbox Code Playgroud)

我尝试了一切,例如将我的项目恢复到以前的版本并使缓存无效并重新启动,但错误仍然存​​在我真的不知道发生了什么:

这是我的毕业证书:

ext {
    configuration = [
            compileVersion: 27,
            minSdk        : 14,
            targetSdk     : 25,
            version_code  : 5,
            version_name  : "1.0.0"
    ]

    libraries = [
            supportVersion: '1.0.0-beta01'
    ]
}
buildscript {
    ext.kotlin_version = '1.3.50'

    repositories {
        google()
        jcenter()
        maven {
            url 'https://maven.fabric.io/public'
        }
    }
    dependencies {

        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath 'com.google.gms:google-services:4.2.0'
        classpath "io.realm:realm-gradle-plugin:6.0.1"
        classpath 'io.fabric.tools:gradle:1.27.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

//        classpath "com.android.tools.build:gradle:${buildConfig.gradlePlugin}"

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

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

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

构建gradle文件:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
apply plugin: 'io.fabric'

apply plugin: 'kotlin-kapt'

apply plugin: 'realm-android'

android {
    compileSdkVersion 29
    defaultConfig {
        applicationId "com.social.media.post.graphics.template.card.maker"
        minSdkVersion 21
        targetSdkVersion 29
        versionCode 6
        versionName "1.5"

        multiDexEnabled true

        vectorDrawables.useSupportLibrary = true

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    dexOptions {
        jumboMode true
        javaMaxHeapSize "4g"
    }
    compileOptions {
        sourceCompatibility = 1.8
        targetCompatibility = 1.8
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.github.smarteist:autoimageslider:1.3.2'
    implementation 'me.grantland:autofittextview:0.2.1'
    //noinspection GradleCompatible
    implementation 'org.greenrobot:eventbus:3.1.1'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'com.google.android.material:material:1.1.0-alpha10'
    implementation 'com.github.QuadFlask:colorpicker:0.0.13'
    implementation 'com.github.kaushikthedeveloper:squarelayout:0.0.3'
    implementation project(':imagelibrary')
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'com.github.bumptech.glide:glide:4.10.0'
    implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
    implementation 'com.intuit.sdp:sdp-android:1.0.5'
    implementation 'com.intuit.ssp:ssp-android:1.0.5'
    implementation 'androidx.percentlayout:percentlayout:1.0.0'
    implementation 'com.github.MasayukiSuda:BubbleLayout:v1.2.1'
    //Fuel
    implementation 'com.github.kittinunf.fuel:fuel:2.2.1'
    implementation 'com.github.kittinunf.fuel:fuel-android:2.2.1'
    implementation 'com.github.kittinunf.fuel:fuel-gson:2.2.1'

    implementation 'com.google.android.material:material:1.0.0'
    //Gson
    implementation 'com.google.code.gson:gson:2.7'
    implementation 'com.github.fondesa:kpermissions:2.0.2'
    //Coroutines
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.0'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:0.30.1-eap13'
    implementation 'com.isseiaoki:simplecropview:1.1.4'
    implementation 'com.github.hotchemi:permissionsdispatcher:2.3.1'
    annotationProcessor 'com.github.hotchemi:permissionsdispatcher-processor:2.3.1'
    // all common code dependencies
    implementation 'com.eyalbira.loadingdots:loading-dots:1.0.2'
    implementation 'androidx.multidex:multidex:2.0.1'
    implementation 'com.google.code.gson:gson:2.8.5'
    implementation 'com.github.sujithkanna:smileyrating:1.6.8'
    implementation 'com.daimajia.slider:library:1.1.5@aar'
    implementation 'com.nineoldandroids:library:2.4.0'
    implementation 'com.github.warkiz.widget:indicatorseekbar:2.1.2'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.3.0-alpha02'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0-alpha02'
    implementation 'com.github.Theophrast:SquareImageView:1.0.1'
    //For Firebase
    implementation 'com.google.firebase:firebase-core:17.2.0'
    implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
    //For Google Mediation
    implementation 'com.google.android.gms:play-services-ads:18.2.0'
    // For Fb Mediation and FB ads
    implementation 'com.facebook.android:audience-network-sdk:5.6.0'
    implementation 'com.google.ads.mediation:facebook:5.6.0.0'
    implementation 'com.makeramen:roundedimageview:2.3.0'
    //for unzip .zip file
    implementation 'com.github.ghost1372:Mzip-Android:0.4.0'
    //lottie animation
    implementation 'com.airbnb.android:lottie:3.0.7'
    // for equal spacing around recycler view
    /* implementation('com.github.thekhaeng:recycler-margin:1.2.1') {
            exclude group: 'com.android.support', module: 'recyclerview-v7'
        }*/
    // subscribe and in - app
    implementation 'com.anjlab.android.iab.v3:library:1.0.44'
    implementation 'androidx.core:core-ktx:+'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    //Sectioned Recyclerview
    implementation 'com.github.IntruderShanky:Sectioned-RecyclerView:2.1.1'
    //Ripple Effect
    implementation 'com.github.traex.rippleeffect:library:1.3'
    //Tagview
    compile 'com.veinhorn.tagview:library:1.0.4'
}
apply plugin: 'com.google.gms.google-services'
repositories {
    mavenCentral()
}
Run Code Online (Sandbox Code Playgroud)

Nab*_*bzi 46

我有同样的错误,它与同名的 kotlin 和 java 文件有关。

在我将一个 java 文件在一个分支中转换为 kotlin,然后合并我的分支后,问题出现了,但两个文件都保留在项目中。

错误没有显示重复的文件名,但添加后

kapt.incremental.apt=false
Run Code Online (Sandbox Code Playgroud)

到本文建议的“gradle.properties”:

https://medium.com/@tashpemhiwa/after-a-rather-long-hiatus-without-writing-an-article-i-have-had-recent-new-inspiration-to-start-7f1f5187ba53

禁用增量构建后,我的构建结果中出现重复文件错误,我知道重复的文件名,所以我删除了java文件。

之后我启用了增量 kapt,因为增量构建速度更快。


Mar*_*ues 0

我已经遇到过几次这个问题了。

唯一对我有用的是升级/降级 Android Gradle 插件。尝试使用 3.5.3。

就我而言,我使用的是 3.6.0-rc02。降级到 3.5.3 后,问题就消失了。