Kotlin房间数据库崩溃在kotlin 1.2.40版本上

时间:2018-04-25 09:28:16

标签: android kotlin android-room

升级到kotlin 1.2.40后,我在构建时遇到以下错误:

e: [kapt] An exception occurred: java.lang.NoClassDefFoundError: org/jetbrains/kotlin/serialization/jvm/JvmProtoBufUtil
at me.eugeniomarletti.kotlin.metadata.KotlinClassMetadata$data$2.invoke(KotlinMetadata.kt:51)
at me.eugeniomarletti.kotlin.metadata.KotlinClassMetadata$data$2.invoke(KotlinMetadata.kt:50)
at kotlin.SynchronizedLazyImpl.getValue(Lazy.kt:131)
at me.eugeniomarletti.kotlin.metadata.KotlinClassMetadata.getData(KotlinMetadata.kt)
at android.arch.persistence.room.ext.KotlinMetadataProcessor$DefaultImpls.getParameterNames(KotlinMetadataProcessor.kt:33)
at android.arch.persistence.room.processor.PojoProcessor.getParameterNames(PojoProcessor.kt:73)
at android.arch.persistence.room.processor.PojoProcessor.getParamNames(PojoProcessor.kt:245)
at android.arch.persistence.room.processor.PojoProcessor.chooseConstructor(PojoProcessor.kt:263)
at android.arch.persistence.room.processor.PojoProcessor.doProcess(PojoProcessor.kt:207)
at android.arch.persistence.room.processor.PojoProcessor.access$doProcess(PojoProcessor.kt:73)
at android.arch.persistence.room.processor.PojoProcessor$process$1.invoke(PojoProcessor.kt:104)
at android.arch.persistence.room.processor.PojoProcessor$process$1.invoke(PojoProcessor.kt:73)
at android.arch.persistence.room.processor.cache.Cache$Bucket.get(Cache.kt:46)
at android.arch.persistence.room.processor.PojoProcessor.process(PojoProcessor.kt:101)
at android.arch.persistence.room.processor.EntityProcessor.doProcess(EntityProcessor.kt:68)
at android.arch.persistence.room.processor.EntityProcessor.access$doProcess(EntityProcessor.kt:50)
at android.arch.persistence.room.processor.EntityProcessor$process$1.invoke(EntityProcessor.kt:57)
at android.arch.persistence.room.processor.EntityProcessor$process$1.invoke(EntityProcessor.kt:50)
at android.arch.persistence.room.processor.cache.Cache$Bucket.get(Cache.kt:46)
at android.arch.persistence.room.processor.EntityProcessor.process(EntityProcessor.kt:56)
at android.arch.persistence.room.processor.DatabaseProcessor.processEntities(DatabaseProcessor.kt:248)
at android.arch.persistence.room.processor.DatabaseProcessor.doProcess(DatabaseProcessor.kt:63)
at android.arch.persistence.room.processor.DatabaseProcessor.process(DatabaseProcessor.kt:53)
at android.arch.persistence.room.RoomProcessor$DatabaseProcessingStep.process(RoomProcessor.kt:57)
at com.google.auto.common.BasicAnnotationProcessor.process(BasicAnnotationProcessor.java:318)
at com.google.auto.common.BasicAnnotationProcessor.process(BasicAnnotationProcessor.java:171)
at org.jetbrains.kotlin.kapt3.ProcessorWrapper.process(annotationProcessing.kt:131)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:794)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:705)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1800(JavacProcessingEnvironment.java:91)
at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1039)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1180)
at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)
at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1068)
at org.jetbrains.kotlin.kapt3.AnnotationProcessingKt.doAnnotationProcessing(annotationProcessing.kt:87)
at org.jetbrains.kotlin.kapt3.AnnotationProcessingKt.doAnnotationProcessing$default(annotationProcessing.kt:45)
at org.jetbrains.kotlin.kapt3.AbstractKapt3Extension.runAnnotationProcessing(Kapt3Extension.kt:257)
at org.jetbrains.kotlin.kapt3.AbstractKapt3Extension.analysisCompleted(Kapt3Extension.kt:212)
at org.jetbrains.kotlin.kapt3.ClasspathBasedKapt3Extension.analysisCompleted(Kapt3Extension.kt:95)
at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM$analyzeFilesWithJavaIntegration$2.invoke(TopDownAnalyzerFacadeForJVM.kt:97)
at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(TopDownAnalyzerFacadeForJVM.kt:107)
at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration$default(TopDownAnalyzerFacadeForJVM.kt:84)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:374)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:64)
at org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport.analyzeAndReport(AnalyzerWithCompilerReport.kt:101)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyze(KotlinToJVMBytecodeCompiler.kt:365)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:130)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:161)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:63)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.java:107)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.java:51)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:96)
at org.jetbrains.kotlin.daemon.CompileServiceImpl$compile$1$1$2.invoke(CompileServiceImpl.kt:405)
at org.jetbrains.kotlin.daemon.CompileServiceImpl$compile$1$1$2.invoke(CompileServiceImpl.kt:98)
at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$$inlined$ifAlive$lambda$2.invoke(CompileServiceImpl.kt:920)
at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$$inlined$ifAlive$lambda$2.invoke(CompileServiceImpl.kt:98)
at org.jetbrains.kotlin.daemon.common.DummyProfiler.withMeasure(PerfUtils.kt:137)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.checkedCompile(CompileServiceImpl.kt:950)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.doCompile(CompileServiceImpl.kt:919)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:404)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:346)
at sun.rmi.transport.Transport$1.run(Transport.java:200)
at sun.rmi.transport.Transport$1.run(Transport.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: org.jetbrains.kotlin.serialization.jvm.JvmProtoBufUtil
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 77 more

在我的build-gradle中更改为版本1.2.30之后,构建工作正常,但现在我在gradle(1.2.30)使用的版本和捆绑到IDE插件(1.2.40)中的版本之间存在不匹配

新kotlin版本有什么问题吗?或者我如何降级到1.2.30版本?

感谢您的关注。

2 个答案:

答案 0 :(得分:1)

您可以通过下载与您的Android工作室版本对应的插件zip来降级:http://plugins.jetbrains.com/plugin/6954-kotlin

使用Settings | Plugins | Install plugin from disk并选择下载的zip文件。

答案 1 :(得分:1)

问题在于他们在Kotlin 1.2.40 1.2.30中引入了二元不兼容性。现在有几个选择:

  1. 将Kotlin降级为1.1.0

  2. 将最新的Kotlin版本与稳定会议室版本(kotlin-compiler-embeddable)一起使用。然后,您必须替换1.1.0-rc1依赖项(见下文)。

  3. 将最新的Kotlin版本与最新会议室版本(build.gradle)一起使用。他们修复了RC1中的错误。

  4. 我会使用3d方式并密切​​关注Room的发布。但如果你选择第二个,那么你必须在 root subprojects { configurations.all { resolutionStrategy { eachDependency { if (requested.name == "kotlin-compiler-embeddable") { useVersion("1.2.30") } } } } } 中插入它:

    BusinessNetworkDefinition