Kotlin / kotlinx.serialization

Kotlin multiplatform / multi-format serialization
Apache License 2.0
5.36k stars 619 forks source link

Compatibility issue with Kotlin 1.3.72 #813

Closed bviale closed 2 years ago

bviale commented 4 years ago

Describe the bug Hello, I am building an Android app and I have the following Gradle error while trying to build a project with version 0.20.0 and Kotlin version 1.3.72 :

java.lang.AbstractMethodError: Receiver class org.jetbrains.kotlinx.serialization.compiler.extensions.SerializationLoweringExtension does not define or inherit an implementation of the resolved method 'abstract void generate(org.jetbrains.kotlin.ir.declarations.IrFile, org.jetbrains.kotlin.backend.common.BackendContext, org.jetbrains.kotlin.resolve.BindingContext)' of interface org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension.

To Reproduce Here is my project build.gradle :

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.3.72'
    repositories {
        google()
        jcenter()
        maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.0-alpha06'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"

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

allprojects {
    repositories {
        google()
        jcenter()
        maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
    }
}

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

And my module build.gradle :

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlinx-serialization'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.3"

    defaultConfig {
        applicationId "com.bviale.tasker"
        minSdkVersion 26
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildFeatures {
        // Enables Jetpack Compose for this module
        compose true
    }

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

// To inline the bytecode built with JVM target 1.8 into
// bytecode that is being built with JVM target 1.6. (e.g. navArgs)

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = "1.8"
    }
    composeOptions {
        kotlinCompilerExtensionVersion "0.1.0-dev09"
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.20.0" // JVM dependency
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.core:core-ktx:1.2.0'
    implementation 'com.google.android.material:material:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.navigation:navigation-fragment-ktx:2.2.2'
    implementation 'androidx.navigation:navigation-ui-ktx:2.2.2'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    def lifecycle_version = "2.2.0"
    implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
    implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
    def ui_version = "0.1.0-dev09"
    implementation "androidx.ui:ui-framework:$ui_version"
    implementation "androidx.ui:ui-tooling:$ui_version"
    implementation "androidx.ui:ui-layout:$ui_version"
    implementation "androidx.ui:ui-material:$ui_version"
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

    implementation 'com.github.bumptech.glide:glide:4.11.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
}

Expected behavior

Environment

sandwwraith commented 4 years ago

It's likely an incompatibility with Jetpack Compose

esdudnik commented 4 years ago

Received the same error, when update kotlin version in my multiplatform project.

teddybee commented 4 years ago

This helps temporarily on jetpack compose errors: composeOptions { kotlinCompilerVersion "1.3.70-dev-withExperimentalGoogleExtensions-20200424" kotlinCompilerExtensionVersion = "0.1.0-dev11" }

kyodgorbek commented 4 years ago

This helps temporarily on jetpack compose errors: composeOptions { kotlinCompilerVersion "1.3.70-dev-withExperimentalGoogleExtensions-20200424" kotlinCompilerExtensionVersion = "0.1.0-dev11" }

but I am getting following exception after using your suggestion Could not resolve androidx.ui:ui-framework:0.1.0-dev11

bachiri commented 4 years ago

@kyodgorbek You should delete the framework dependency and refer to the official release page to see if there is any API method migration https://developer.android.com/jetpack/androidx/releases/compose

wolecode commented 3 years ago

@bviale I am currently faced with this same issue. Please, how were you able to fix it.