Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio Kotlin Complier Error node.sym must not be null

Suddenly my android studio gradle build fails with unknown error:

java.lang.IllegalStateException: failed to analyze: com.sun.tools.javac.util.ClientCodeException: java.lang.IllegalStateException: node.sym must not be null

I tried everything like reverting my project back to previous version and invaliding cache and restart but still the error persists i don't really know what is happening:

Here is my gradle:

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
}

Build gradle file:

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()
}
like image 339
R.Coder Avatar asked Feb 04 '20 06:02

R.Coder


2 Answers

I had the same error, and it was related to kotlin and java files with the same name.

The issue appeared after I converted a java file to kotlin in one branch, and then merged my branches, but both files remained in the project.

The error didn't show the duplicated file name, but after adding

kapt.incremental.apt=false

to "gradle.properties" as suggested by this article:

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

after disabling incremental build, the duplicate file error appeared in my build results and I knew the duplicated file name, so I removed the java file.

I enabled incremental kapt afterwards, because incremental build is faster.

like image 106
Nabzi Avatar answered Oct 03 '22 22:10

Nabzi


It also happened when source is set like:

sourceSets {
    main {
        java.srcDirs += 'build/generated/data_binding_base_class_source_out/'
    }
 }

And there are multiple build types. Folders in data_binding_base_class_source_out intercepts and it causes the problem.

Fix:

sourceSets {
    debug {
          java.srcDirs += 'build/generated/data_binding_base_class_source_out/debug/'
    }
    release {
        java.srcDirs += 'build/generated/data_binding_base_class_source_out/release/'
    }
}
like image 29
Mike Avatar answered Oct 03 '22 20:10

Mike