Android Plugin 2.2.0-alpha1无法与Kotlin编译
升级到Android构建工具2.2.0-alpha1后。 我无法配置应用程序或构建。
我从gradle得到以下堆栈跟踪:
e: java.lang.IllegalStateException: Built-in library initialization failed. Please ensure you have kotlin-runtime.jar in the classpath: java.lang.NoSuchMethodError: com.google.protobuf.GeneratedMessageLite.newSingularGeneratedExtension(Lcom/google/protobuf/MessageLite;Ljava/lang/Object;Lcom/google/protobuf/MessageLite;Lcom/google/protobuf/Internal$EnumLiteMap;ILcom/google/protobuf/WireFormat$FieldType;)Lcom/google/protobuf/GeneratedMessageLite$GeneratedExtension; at org.jetbrains.kotlin.builtins.BuiltInsInitializer.initialize(BuiltInsInitializer.kt:45) at org.jetbrains.kotlin.builtins.BuiltInsInitializer.get(BuiltInsInitializer.kt:62) at org.jetbrains.kotlin.platform.JvmBuiltIns$Companion.getInstance(JvmBuiltIns.kt:32) at org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform.getBuiltIns(JvmPlatform.kt:41) at org.jetbrains.kotlin.resolve.TargetPlatformKt.createModule(TargetPlatform.kt:112) at org.jetbrains.kotlin.resolve.TargetPlatformKt.createModule$default(TargetPlatform.kt:111) at org.jetbrains.kotlin.context.ContextKt.ContextForNewModule(context.kt:124) at org.jetbrains.kotlin.resolve.jvm.TopDownAnalyzerFacadeForJVM.createContextWithSealedModule(TopDownAnalyzerFacadeForJVM.java:163) at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.analyze(KotlinToJVMBytecodeCompiler.kt:322) at org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport.analyzeAndReport(AnalyzerWithCompilerReport.kt:129) at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyze(KotlinToJVMBytecodeCompiler.kt:318) at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules(KotlinToJVMBytecodeCompiler.kt:124) at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:173) at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:49) at org.jetbrains.kotlin.cli.common.CLICompiler.exec(CLICompiler.java:220) at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.compileNotIncremental(Tasks.kt:497) at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.callCompiler(Tasks.kt:370) at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.callCompiler(Tasks.kt:149) at org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile.execute(Tasks.kt:110) 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 org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75) at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.doExecute(AnnotationProcessingTaskFactory.java:245) at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:221) at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.execute(AnnotationProcessingTaskFactory.java:232) at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:210) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46) at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35) at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:68) at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58) at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:52) at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52) at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53) at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43) at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:203) at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:185) at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:66) at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:50) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54) at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40) 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.NoSuchMethodError: com.google.protobuf.GeneratedMessageLite.newSingularGeneratedExtension(Lcom/google/protobuf/MessageLite;Ljava/lang/Object;Lcom/google/protobuf/MessageLite;Lcom/google/protobuf/Internal$EnumLiteMap;ILcom/google/protobuf/WireFormat$FieldType;)Lcom/google/protobuf/GeneratedMessageLite$GeneratedExtension; at org.jetbrains.kotlin.serialization.builtins.BuiltInsProtoBuf.<clinit>(BuiltInsProtoBuf.java:879) at org.jetbrains.kotlin.builtins.BuiltInSerializerProtocol.<init>(BuiltInSerializerProtocol.kt:25) at org.jetbrains.kotlin.builtins.BuiltInSerializerProtocol.<clinit>(BuiltInSerializerProtocol.kt:24) at org.jetbrains.kotlin.builtins.BuiltInsPackageFragment.<init>(BuiltInsPackageFragment.kt:34) at org.jetbrains.kotlin.builtins.BuiltInsPackageFragmentProviderKt.createBuiltInPackageFragmentProvider(builtInsPackageFragmentProvider.kt:37) at org.jetbrains.kotlin.builtins.KotlinBuiltIns.<init>(KotlinBuiltIns.java:84) at org.jetbrains.kotlin.platform.JvmBuiltIns.<init>(JvmBuiltIns.kt:24) at org.jetbrains.kotlin.platform.JvmBuiltIns.<init>(JvmBuiltIns.kt:24) at org.jetbrains.kotlin.platform.JvmBuiltIns$Companion$initializer$1.invoke(JvmBuiltIns.kt:27) at org.jetbrains.kotlin.platform.JvmBuiltIns$Companion$initializer$1.invoke(JvmBuiltIns.kt:25) at org.jetbrains.kotlin.builtins.BuiltInsInitializer.initialize(BuiltInsInitializer.kt:41) ... 46 more e: java.lang.AssertionError: Built-ins are not initialized (note: We are under the same lock as initializing and instance) at org.jetbrains.kotlin.builtins.BuiltInsInitializer.get(BuiltInsInitializer.kt:57) at org.jetbrains.kotlin.platform.JvmBuiltIns$Companion.getInstance(JvmBuiltIns.kt:32) at org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform.getBuiltIns(JvmPlatform.kt:41) at org.jetbrains.kotlin.resolve.TargetPlatformKt.createModule(TargetPlatform.kt:112) at org.jetbrains.kotlin.resolve.TargetPlatformKt.createModule$default(TargetPlatform.kt:111) at org.jetbrains.kotlin.context.ContextKt.ContextForNewModule(context.kt:124) at org.jetbrains.kotlin.resolve.jvm.TopDownAnalyzerFacadeForJVM.createContextWithSealedModule(TopDownAnalyzerFacadeForJVM.java:163) at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.analyze(KotlinToJVMBytecodeCompiler.kt:322) at org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport.analyzeAndReport(AnalyzerWithCompilerReport.kt:129) at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyze(KotlinToJVMBytecodeCompiler.kt:318) at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules(KotlinToJVMBytecodeCompiler.kt:124) at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:173) at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:49) at org.jetbrains.kotlin.cli.common.CLICompiler.exec(CLICompiler.java:220) at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.compileNotIncremental(Tasks.kt:497) at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.callCompiler(Tasks.kt:370) at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.callCompiler(Tasks.kt:149) at org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile.execute(Tasks.kt:110) 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 org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75) at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.doExecute(AnnotationProcessingTaskFactory.java:245) at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:221) at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.execute(AnnotationProcessingTaskFactory.java:232) at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:210) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46) at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35) at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:68) at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58) at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:52) at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52) at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53) at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43) at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:203) at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:185) at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:66) at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:50) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54) at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40) 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)
这似乎是一个依赖的问题,新的Android Gradle插件包括Kotlin,但是一个老版本。
目前的工作是重新安排类库路径的依赖关系,把kotlin插件放在android之前。
dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "com.android.tools.build:gradle:$gradle_tools_version" }
查看正在跟踪的问题: https : //youtrack.jetbrains.com/issue/KT-12431
- Android Studio 3.0和gradle升级 – 创建apk时缺少base.apk代码
- Kotlin,Java,multidex,Dagger 2,Butterknife和Realm:transformClassesWithMargingForDebug:重复条目:org / jetbrains / annotations / NotNull.class
- MyObjectBox不是在kotlin(objectbox库)中生成的
- 由于重复,Kotlin gradle.build ZipException
- 升级到android gradle插件3.0.0+后,项目不会生成
- 进口不在Android Studio中使用
- 如何在OS X上使用Intellij IDEA 15.2从Git repo中构建Android项目
- Gradle同步失败:原因:com / android / build / gradle / BaseExtension
- Android工作室插件ID:'kotlin-android-extensions'