这是第一次发生这种情况,当我使用 kotlin 在 android studio 上运行应用程序时,即使使用默认应用程序,android studio 创建它也会给我这个错误,模拟器打开应用程序但 insta 崩溃并显示消息: “应用程序已停止”
这是有错误的日志:
2021-06-06 19:22:42.598 7817-7817/com.example.myapplication E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.myapplication, PID: 7817
java.lang.NoSuchMethodError: No static method drawRect-w2WG-Gw$default(Landroidx/compose/ui/graphics/drawscope/DrawScope;JJJFLandroidx/compose/ui/graphics/drawscope/DrawStyle;Landroidx/compose/ui/graphics/ColorFilter;Landroidx/compose/ui/graphics/BlendMode;ILjava/lang/Object;)V in class Landroidx/compose/ui/graphics/drawscope/DrawScope$DefaultImpls; or its super classes (declaration of 'androidx.compose.ui.graphics.drawscope.DrawScope$DefaultImpls' appears in /data/app/~~1FERHlT2eRJdt1EprXEfMQ==/com.example.myapplication-m2_HPlQabeWTbDjc_hkOyA==/base.apk)
at androidx.compose.foundation.Background.drawRect(Background.kt:111)
at androidx.compose.foundation.Background.draw(Background.kt:103)
at androidx.compose.ui.node.ModifiedDrawNode.performDraw(ModifiedDrawNode.kt:102)
at androidx.compose.ui.node.LayoutNodeWrapper$invoke$1.invoke(LayoutNodeWrapper.kt:260)
at androidx.compose.ui.node.LayoutNodeWrapper$invoke$1.invoke(LayoutNodeWrapper.kt:259)
at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:121)
at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui_release(OwnerSnapshotObserver.kt:75)
at androidx.compose.ui.node.LayoutNodeWrapper.invoke(LayoutNodeWrapper.kt:259)
at androidx.compose.ui.node.LayoutNodeWrapper.invoke(LayoutNodeWrapper.kt:53)
at androidx.compose.ui.platform.RenderNodeApi29.record(RenderNodeApi29.android.kt:156)
at androidx.compose.ui.platform.RenderNodeLayer.updateDisplayList(RenderNodeLayer.android.kt:229)
at androidx.compose.ui.platform.RenderNodeLayer.drawLayer(RenderNodeLayer.android.kt:210)
at androidx.compose.ui.node.LayoutNodeWrapper.draw(LayoutNodeWrapper.kt:244)
at androidx.compose.ui.node.ModifiedLayoutNode.performDraw(ModifiedLayoutNode.kt:82)
at androidx.compose.ui.node.LayoutNodeWrapper$invoke$1.invoke(LayoutNodeWrapper.kt:260)
at androidx.compose.ui.node.LayoutNodeWrapper$invoke$1.invoke(LayoutNodeWrapper.kt:259)
at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:1788)
at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:116)
at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui_release(OwnerSnapshotObserver.kt:75)
at androidx.compose.ui.node.LayoutNodeWrapper.invoke(LayoutNodeWrapper.kt:259)
at androidx.compose.ui.node.LayoutNodeWrapper.invoke(LayoutNodeWrapper.kt:53)
at androidx.compose.ui.platform.RenderNodeApi29.record(RenderNodeApi29.android.kt:156)
at androidx.compose.ui.platform.RenderNodeLayer.updateDisplayList(RenderNodeLayer.android.kt:229)
at androidx.compose.ui.platform.RenderNodeLayer.drawLayer(RenderNodeLayer.android.kt:210)
at androidx.compose.ui.node.LayoutNodeWrapper.draw(LayoutNodeWrapper.kt:244)
at androidx.compose.ui.node.LayoutNode.draw$ui_release(LayoutNode.kt:800)
at androidx.compose.ui.node.InnerPlaceable.performDraw(InnerPlaceable.kt:116)
at androidx.compose.ui.node.LayoutNodeWrapper.draw(LayoutNodeWrapper.kt:249)
at androidx.compose.ui.node.DelegatingLayoutNodeWrapper.performDraw(DelegatingLayoutNodeWrapper.kt:67)
at androidx.compose.ui.node.LayoutNodeWrapper.draw(LayoutNodeWrapper.kt:249)
at androidx.compose.ui.node.DelegatingLayoutNodeWrapper.performDraw(DelegatingLayoutNodeWrapper.kt:67)
at androidx.compose.ui.node.LayoutNodeWrapper.draw(LayoutNodeWrapper.kt:249)
at androidx.compose.ui.node.DelegatingLayoutNodeWrapper.performDraw(DelegatingLayoutNodeWrapper.kt:67)
at androidx.compose.ui.node.LayoutNodeWrapper.draw(LayoutNodeWrapper.kt:249)
at androidx.compose.ui.node.DelegatingLayoutNodeWrapper.performDraw(DelegatingLayoutNodeWrapper.kt:67)
at androidx.compose.ui.node.LayoutNodeWrapper.draw(LayoutNodeWrapper.kt:249)
at androidx.compose.ui.node.LayoutNode.draw$ui_release(LayoutNode.kt:800)
at androidx.compose.ui.platform.AndroidComposeView.dispatchDraw(AndroidComposeView.android.kt:656)
at android.view.View.draw(View.java:22353)
2021-06-06 19:22:42.599 7817-7817/com.example.myapplication E/AndroidRuntime: at android.view.View.updateDisplayListIfDirty(View.java:21226)
at android.view.View.draw(View.java:22081)
at android.view.ViewGroup.drawChild(ViewGroup.java:4516)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4277)
at android.view.View.updateDisplayListIfDirty(View.java:21217)
at android.view.View.draw(View.java:22081)
at android.view.ViewGroup.drawChild(ViewGroup.java:4516)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4277)
at android.view.View.updateDisplayListIfDirty(View.java:21217)
at android.view.View.draw(View.java:22081)
at android.view.ViewGroup.drawChild(ViewGroup.java:4516)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4277)
at android.view.View.updateDisplayListIfDirty(View.java:21217)
at android.view.View.draw(View.java:22081)
at android.view.ViewGroup.drawChild(ViewGroup.java:4516)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4277)
at android.view.View.draw(View.java:22353)
at com.android.internal.policy.DecorView.draw(DecorView.java:806)
at android.view.View.updateDisplayListIfDirty(View.java:21226)
at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:559)
at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:565)
at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:642)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:4101)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:3828)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3099)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1952)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8171)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:972)
at android.view.Choreographer.doCallbacks(Choreographer.java:796)
at android.view.Choreographer.doFrame(Choreographer.java:731)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:957)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
知道如何解决吗?
答案 0 :(得分:2)
我通过将 compose 版本更新为 1.0.0-beta08 并将 kotlinCompilerVersion 更新为 1.5.0 在应用程序 gradle 文件和 (classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.10 ") 在项目 gradle 文件中,它对我有用
答案 1 :(得分:0)
当您的视图没有出现或出现问题时,Android 应用程序会给出一个FATAL EXCEPTION 错误 请检查您的观点或观看任何演员。