Kotlin-Singleton-Example icon indicating copy to clipboard operation
Kotlin-Singleton-Example copied to clipboard

This example crashes on load

Open Stigmaru opened this issue 4 years ago • 0 comments

Running the latest 1.5.0 kotlin compiler and Canary 2021.1.1 Bumblebee on the Composable template. I can't get this to load. The app crashes immediately upon starting up. Also tried to switch to new lifecycle dependencies and it made no difference. Looks like it never completes the "viewModel.setUserId("1")" line. Is there a new update to ViewModels that breaks this example?

See below Gradle file:


plugins {
    id 'com.android.application'
    id 'kotlin-android'
    //id 'kotlin-android-extensions'
}

android {
    compileSdk 30
    buildToolsVersion "30.0.3"

    defaultConfig {
        applicationId "com.urbineer.wirelessrollers"
        minSdk 21
        targetSdk 30
        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 {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
        useIR = true
    }
    buildFeatures {
        compose true
    }
    composeOptions {
        kotlinCompilerExtensionVersion compose_version
        kotlinCompilerVersion '1.5.0'
    }
}

dependencies {

    implementation 'androidx.core:core-ktx:1.6.0'
    implementation 'androidx.appcompat:appcompat:1.3.0'
    implementation 'com.google.android.material:material:1.4.0'
    implementation "androidx.compose.ui:ui:$compose_version"
    implementation "androidx.compose.material:material:$compose_version"
    implementation "androidx.compose.ui:ui-tooling:$compose_version"
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
    implementation 'androidx.activity:activity-compose:1.3.0-rc01'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"

    implementation 'com.google.code.gson:gson:2.8.6'

    implementation fileTree(dir: 'libs', include: ['*.jar'])
    //implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

    //def lifecycle_version = "2.2.0-alpha03"
    //implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$LIFECYCLE_VERSION" // for viewModelScope
    implementation "androidx.lifecycle:lifecycle-runtime-ktx:$LIFECYCLE_VERSION" // for lifecycleScope


    // -- Retrofit2
    def retrofit2_version = "2.6.0"
    implementation "com.squareup.retrofit2:retrofit:$retrofit2_version"
    implementation "com.squareup.retrofit2:converter-gson:$retrofit2_version"

    // -- Coroutines
    def coroutines_version = "1.2.1"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
}

Stigmaru avatar Jul 08 '21 01:07 Stigmaru