迁移到新的 jetpack compose 版本时出错 [英] Error migrating to new jetpack compose version

查看:77
本文介绍了迁移到新的 jetpack compose 版本时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将我的应用更新到新的撰写版本,但它给了我一个我不知道如何修复的错误.当我运行时,错误仍然存​​在于我的运行中.我的旧项目正常运行,但我想要的是更改版本,如果有人可以帮助我,我会很感激

I'm trying to update my app to a new compose version but it gave me an error that I don't know how to fix. when I run the error persists in my run. my old project works normally but mine what I want is to change versions follow my error if anyone can help me i would appreciate it a lot

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.quitanda, PID: 10390
    java.lang.AbstractMethodError: abstract method "void androidx.lifecycle.DefaultLifecycleObserver.onCreate(androidx.lifecycle.LifecycleOwner)"
        at androidx.lifecycle.FullLifecycleObserverAdapter.onStateChanged(FullLifecycleObserverAdapter.java:36)
        at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.java:354)
        at androidx.lifecycle.LifecycleRegistry.addObserver(LifecycleRegistry.java:196)
        at androidx.compose.ui.platform.AndroidComposeView.onAttachedToWindow(AndroidComposeView.android.kt:808)
        at android.view.View.dispatchAttachedToWindow(View.java:18355)
        at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3399)
        at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3406)
        at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3406)
        at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3406)
        at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3406)
        at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1796)
        at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1494)
        at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7288)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:949)
        at android.view.Choreographer.doCallbacks(Choreographer.java:761)
        at android.view.Choreographer.doFrame(Choreographer.java:696)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:935)
        at android.os.Handler.handleCallback(Handler.java:873)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6923)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:870)

build.gradle(项目)

build.gradle(Project)

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

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

buildscript {
    ext {
        compose_version = '1.0.0-rc01'
    }
}

build.gradle(模块)

build.gradle(Module)

plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
}

apply plugin:'kotlin-parcelize'

android {
    compileSdk 30

    defaultConfig {
        applicationId "com.example.quitanda"
        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'
    }
    buildFeatures {
        compose true
    }
    composeOptions {
        kotlinCompilerExtensionVersion compose_version
    }
}

dependencies {
    def appcompat_version = "1.3.0"

    implementation 'androidx.hilt:hilt-navigation-compose:1.0.0-alpha02'

    implementation 'androidx.core:core-ktx:1.6.0'
    implementation "androidx.compose.ui:ui:$compose_version"
    implementation "androidx.compose.material:material:$compose_version"
    implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
    implementation 'androidx.activity:activity-compose:1.3.0-rc01'

    implementation "androidx.appcompat:appcompat:$appcompat_version"
    // For loading and tinting drawables on older versions of the platform
    implementation "androidx.appcompat:appcompat-resources:$appcompat_version"

    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"
    debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"


   // implementation "com.google.accompanist:accompanist-coil:0.7.1"
    implementation "io.coil-kt:coil-compose:1.3.0"
    implementation "androidx.navigation:navigation-compose:2.4.0-alpha05"
    implementation "com.google.accompanist:accompanist-swiperefresh:0.8.0"
    implementation "com.google.accompanist:accompanist-pager:0.8.1"

    implementation "com.squareup.retrofit2:retrofit:2.9.0"
    implementation "com.squareup.retrofit2:converter-moshi:2.9.0"
    implementation "androidx.paging:paging-compose:1.0.0-alpha08"
}

推荐答案

这是 AGP 的错误.暂时将 minSDKVersion 更改为 24

It is an error with the AGP. Change the minSDKVersion to 24 for now

这篇关于迁移到新的 jetpack compose 版本时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆