Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DatePicker crashes on compose=1.1.1 #138

Closed
evjava opened this issue Mar 17, 2022 · 9 comments
Closed

DatePicker crashes on compose=1.1.1 #138

evjava opened this issue Mar 17, 2022 · 9 comments
Assignees
Labels
bug Something isn't working

Comments

@evjava
Copy link

evjava commented Mar 17, 2022

Stacktrace:
java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/compose/foundation/lazy/GridCells$Fixed; at com.vanpra.composematerialdialogs.datetime.date.DatePickerKt.DayOfWeekHeader(DatePicker.kt:377) at com.vanpra.composematerialdialogs.datetime.date.DatePickerKt.CalendarView(DatePicker.kt:306) at com.vanpra.composematerialdialogs.datetime.date.DatePickerKt.access$CalendarView(DatePicker.kt:1) at com.vanpra.composematerialdialogs.datetime.date.DatePickerKt$DatePickerImpl$1$1.invoke(DatePicker.kt:141) at com.vanpra.composematerialdialogs.datetime.date.DatePickerKt$DatePickerImpl$1$1.invoke(DatePicker.kt:118) ...

The reason is that in 1.1.1 GridCells was moved to .grid subpackage (and btw became stable).
(
old: https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/GridCells
new: https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/grid/GridCells
)

compose-material-dialogs version: 0.7.0

UPDATE: Actually I haven't this problem.. I was wrong about 1.1.1 compose version, I used 1.2.0-alpha05.. 🙈

@evjava evjava added the bug Something isn't working label Mar 17, 2022
@calwi
Copy link

calwi commented Mar 23, 2022

Works for me with compose-1.1.1 and compose-runtime-1.1.1 but not compose-runtime-1.2.0-alpha05.

@srseibs
Copy link

srseibs commented Mar 29, 2022

Is there any workaround for this?

@calwi
Copy link

calwi commented Mar 29, 2022

Is there any workaround for this?

Try with compose runtime set to 1.1.1, that is the "runtime", as a separate dependency library.

@srseibs
Copy link

srseibs commented Mar 29, 2022

Try with compose runtime set to 1.1.1, that is the "runtime", as a separate dependency library.

This had the same error


    java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/compose/foundation/lazy/GridCells$Fixed;
        at com.vanpra.composematerialdialogs.datetime.date.DatePickerKt.DayOfWeekHeader(DatePicker.kt:384)

    compose_version = '1.2.0-alpha06'
    implementation("androidx.compose.compiler:compiler:$compose_version")
    implementation("androidx.compose.foundation:foundation:$compose_version")
    implementation("androidx.compose.runtime:runtime:1.1.1")  // added this here

@calwi
Copy link

calwi commented Mar 29, 2022

Try with compose runtime set to 1.1.1, that is the "runtime", as a separate dependency library.

This had the same error


    java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/compose/foundation/lazy/GridCells$Fixed;
        at com.vanpra.composematerialdialogs.datetime.date.DatePickerKt.DayOfWeekHeader(DatePicker.kt:384)

    compose_version = '1.2.0-alpha06'
    implementation("androidx.compose.compiler:compiler:$compose_version")
    implementation("androidx.compose.foundation:foundation:$compose_version")
    implementation("androidx.compose.runtime:runtime:1.1.1")  // added this here

try... something like... adjust for what you don't need..

    compose_runtime_version = '1.1.1' //''1.2.0-alpha05'
    compose_version = '1.1.1'
    navigation_compose_version = '2.5.0-alpha03'
    constraint_layout_version = '2.1.3'
    constraint_layout_compose_version = '1.0.0'
    activity_compose_version = '1.5.0-alpha03'

with

// Compose Runtime
implementation "androidx.compose.runtime:runtime:$compose_runtime_version"

// Compose UI
implementation "androidx.compose.ui:ui:$compose_runtime_version"
implementation "androidx.compose.ui:ui-tooling:$compose_version"
implementation "androidx.compose.material:material:$compose_runtime_version"
implementation "androidx.navigation:navigation-compose:$navigation_compose_version"
implementation "androidx.constraintlayout:constraintlayout:$constraint_layout_version"
implementation "androidx.constraintlayout:constraintlayout-compose:$constraint_layout_compose_version"
//implementation "androidx.compose.material:material-icons-extended:$compose_version"

// Compose Testing
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"

@srseibs
Copy link

srseibs commented Mar 30, 2022

Still results in the same error....

@calwi
Copy link

calwi commented Mar 30, 2022

Still results in the same error....

I'm using these gradle plugin versions?

    classpath 'com.android.tools.build:gradle:7.1.2'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10" //1.5.31"
    classpath "com.google.dagger:hilt-android-gradle-plugin:$hilt_version"

These library versions:

    compose_runtime_version = '1.1.1' //''1.2.0-alpha05'
    compose_version = '1.1.1'
    navigation_compose_version = '2.5.0-alpha03'
    constraint_layout_version = '2.1.3'
    constraint_layout_compose_version = '1.0.0'
    activity_compose_version = '1.5.0-alpha03'
    hilt_version = '2.40'
    room_version = '2.4.2'
    retrofit_version = '2.9.0'
    lifecycle_version = '2.5.0-alpha03'
    fragment_version = '1.4.1'
    android_material_version = '1.5.0'
    appcompat_version = '1.4.1'
    lifecycle_runtime = '2.4.0'
    lifecycle_runtime_ktx = '2.5.0-alpha04'
    navigation_ktx_version = '2.4.1'
    navigation_ui_ktx_version = '2.4.1'
    core_ktx_version = '1.7.0'
    junit_version = '4.13.2'
    junit_test_extension_version = '1.1.3'
    espresso_core_version = '3.4.0'
    material_datepicker_version = '0.7.0'

These other JVM options...

compileOptions {
    sourceCompatibility JavaVersion.VERSION_11
    targetCompatibility JavaVersion.VERSION_11
}
kotlinOptions {
    jvmTarget = '11'
    useIR = true
}
buildFeatures {
    compose true
}
composeOptions {
    kotlinCompilerExtensionVersion compose_version
}

Not sure what else to suggest... If I use the alpha version of compose_runtime... I get that error. Setting it to 1.1.1 is working ok.

@srseibs
Copy link

srseibs commented Mar 31, 2022

Thanks for all you help, but still no bueno. Same error. Here is my application of your versions.

Project-level build.gradle:

buildscript {
    ext {
        compose_version = '1.1.1'

        // https://github.com/JLLeitschuh/ktlint-gradle/releases
        ktlintPluginVersion = "10.2.0"

        // https://github.com/detekt/detekt/releases
        detektVersion = "1.19.0"

        // https://mvnrepository.com/artifact/com.google.dagger/hilt-android
        hilt_version = '2.40'

        // https://github.com/ben-manes/gradle-versions-plugin
        gradle_version_version = '0.42.0'

        // https://github.com/Kotlin/kotlinx-kover
        kover_version = "0.5.0"

        // https://github.com/google/ksp/releases
        ksp_version = '1.6.10-1.0.4'
    }

    dependencies {
        classpath "com.google.dagger:hilt-android-gradle-plugin:$hilt_version"
        classpath 'com.android.tools.build:gradle:7.1.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10" //1.5.31"
    }


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

plugins {
    id 'com.android.application' version '7.1.2' apply false
    id 'com.android.library' version '7.1.2' apply false
    id 'org.jetbrains.kotlin.android' version '1.6.10' apply false
    id("org.jlleitschuh.gradle.ktlint") version "$ktlintPluginVersion"
    id("io.gitlab.arturbosch.detekt").version "$detektVersion"
    id "com.github.ben-manes.versions" version "$gradle_version_version"
    id("org.jetbrains.kotlinx.kover") version "$kover_version" apply false

}

apply from: "buildscripts/versions.gradle"

subprojects {
    apply from: "../buildscripts/ktlint.gradle"
    apply from: "../buildscripts/detekt.gradle"
    apply from: "../buildscripts/versionsplugin.gradle"
    apply from: "../buildscripts/kover.gradle"
}

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

App-level build.gradle

plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
    id 'kotlin-kapt'
    id 'dagger.hilt.android.plugin'
    id 'com.google.devtools.ksp' version "$ksp_version"
}

android {
    compileSdk 32

    defaultConfig {
        applicationId "com.sailinghawklabs.toa"
        minSdk 21
        targetSdk 32
        versionCode 1
        versionName "1.0"

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

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        coreLibraryDesugaringEnabled true
        sourceCompatibility JavaVersion.VERSION_11
        targetCompatibility JavaVersion.VERSION_11
    }
    kotlinOptions {
        jvmTarget = '11'
        useIR = true
    }
    buildFeatures {
        compose true
    }
    composeOptions {
        kotlinCompilerExtensionVersion compose_version
    }
    packagingOptions {
        resources {
            excludes += '/META-INF/{AL2.0,LGPL2.1}'
        }
    }
}

dependencies {

    //----------------------- experimental suggested by Calwi ----------------
    implementation("androidx.navigation:navigation-compose:2.5.0-alpha03")
    implementation("androidx.constraintlayout:constraintlayout:2.1.3")
    implementation("androidx.constraintlayout:constraintlayout-compose:1.0.0")
    implementation("androidx.activity:activity-compose:1.5.0-alpha03")
    // hilt_version --> 2.40
    // room not hooked up yet...
    // retrofit not hooked up yet...
    implementation("androidx.lifecycle:lifecycle-viewmodel:2.5.0-alpha03")
    implementation("androidx.lifecycle:lifecycle-livedata:2.5.0-alpha03")
    implementation("androidx.lifecycle:lifecycle-runtime:2.4.0")
    // fragment not used
    implementation('com.google.android.material:material:1.5.0')
    implementation("androidx.appcompat:appcompat:1.4.1")
    implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.5.0-alpha04")
    implementation("androidx.navigation:navigation-runtime-ktx:2.4.1")
    implementation("androidx.navigation:navigation-fragment-ktx:2.4.1")
    implementation("androidx.navigation:navigation-ui-ktx:2.4.1")
    implementation("androidx.core:core-ktx:1.7.0")
    testImplementation("junit:junit:4.13.2")
    androidTestImplementation("androidx.test.ext:junit:1.1.3")
    androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0")
    implementation("io.github.vanpra.compose-material-dialogs:datetime:0.7.0")
    //------------------------------------------------------------[end of Calwi]

    // material3
    implementation "androidx.compose.material3:material3:1.0.0-alpha08"

    // compose
    implementation "androidx.compose.ui:ui:$compose_version"
    debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
    implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
    implementation("androidx.compose.compiler:compiler:$compose_version")
    implementation("androidx.compose.foundation:foundation:$compose_version")
    // -- compose testing
    androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
    // compose destinations library
    implementation "io.github.raamcosta.compose-destinations:core:$rootProject.ext.versions.composeDestinations"
    //    implementation "io.github.raamcosta.compose-destinations:animations-core:$rootProject.ext.versions.composeDestinations"
    ksp("io.github.raamcosta.compose-destinations:ksp:1.4.0-beta")
    // testing ----------------------
    testImplementation "io.mockk:mockk:$rootProject.ext.versions.mockk"
    testImplementation "com.google.truth:truth:$rootProject.ext.versions.truth"
    testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$rootProject.ext.versions.kotlinxCoroutines"
    // turbine ----------------------
    implementation "app.cash.turbine:turbine:$rootProject.ext.versions.turbine"
    // hilt --------------------------
    implementation "androidx.hilt:hilt-navigation-compose:$rootProject.ext.versions.hiltNavCompose"
    implementation "com.google.dagger:hilt-android:$hilt_version"
    kapt "com.google.dagger:hilt-compiler:$hilt_version"
    // accompanist ------------------
    implementation "com.google.accompanist:accompanist-insets-ui:$rootProject.ext.versions.accompanist"
    implementation "com.google.accompanist:accompanist-systemuicontroller:$rootProject.ext.versions.accompanist"
    implementation "com.google.accompanist:accompanist-navigation-animation:$rootProject.ext.versions.accompNavAnim"

    coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:1.1.5"

}

// added for Compose Destinations
kotlin {
    sourceSets {
        debug {
            kotlin.srcDir("build/generated/ksp/debug/kotlin")
        }
        release {
            kotlin.srcDir("build/generated/ksp/release/kotlin")
        }
    }
}

@evjava
Copy link
Author

evjava commented Apr 3, 2022

Actually I haven't this problem.. I was wrong about 1.1.1 compose version, I used 1.2.0-alpha05.. 🙈

@srseibs , if you still have such an error, try to check that androidx.compose.foundation.lazy.grid.LazyGrid is inaccessible. (it should be accessible only in 1.2.0-alpha05)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants