Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Plugin 2.2.0-alpha1 fails to compile with Kotlin

After upgrading to Android build tools 2.2.0-alpha1. I can't configure the Application or build.

I get the following stack trace from 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)
like image 358
Chris.Jenkins Avatar asked May 24 '16 09:05

Chris.Jenkins


1 Answers

This seems to be a dependency issue where the new Android Gradle Plugin includes Kotlin, but an older version.

The work around for now is to reorder the classpath dependencies putting the kotlin plugin before the android one.

dependencies {
  classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
  classpath "com.android.tools.build:gradle:$gradle_tools_version"
}

See the issue being tracked here: https://youtrack.jetbrains.com/issue/KT-12431

like image 57
Chris.Jenkins Avatar answered Sep 19 '22 23:09

Chris.Jenkins