我正在Android Studio将一个Java Android项目转换为Kotlin,但我遇到了一些问题。
org.gradle.api.GradleException: Internal compiler error. See log for more details
at org.jetbrains.kotlin.gradle.tasks.TasksUtilsKt.throwGradleExceptionIfError(tasksUtils.kt:17)
at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.processCompilerExitCode(Tasks.kt:441)
at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.callCompiler$kotlin_gradle_plugin(Tasks.kt:403)
at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.callCompiler$kotlin_gradle_plugin(Tasks.kt:297)
at org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile.execute(Tasks.kt:259)
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:73)
at org.gradle.api.internal.project.taskfactory.IncrementalTaskAction.doExecute(IncrementalTaskAction.java:50)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:124)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:113)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:95)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:73)
at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:59)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:59)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:101)
at org.gradle.api.internal.tasks.execution.FinalizeInputFilePropertiesTaskExecuter.execute(FinalizeInputFilePropertiesTaskExecuter.java:44)
at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:91)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:62)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:59)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:256)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:249)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:238)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:663)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:597)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
at java.lang.Thread.run(Thread.java:745)
问题来自于转换OnClickListener
s。我检查了您的代码,发现kotlin编译器无法检测到它的lambda形式。尝试更改OnClickListener
s,如下所示:
@Suppress("ObjectLiteralToLambda")
class MainActivity : Activity() {
// private val randomFactListener = OnClickListener {
// // code block
// }
private val randomFactListener = object : OnClickListener {
override fun onClick(v: View?) {
// code block
}
}
// private val backToHomeListener = OnClickListener {
// // code block
// }
private val backToHomeListener = object : OnClickListener {
override fun onClick(v: View?) {
// code block
}
}
// private val anotherRandomFactListener = OnClickListener {
// // code block
// }
private val anotherRandomFactListener = object : OnClickListener {
override fun onClick(v: View?) {
// code block
}
}
}
以下是您更正的mainactivity.kt
完整源代码。
我是Android Studio的初学者,我希望主要活动是在java上而不是在kotlin上。我测试了一些可用的堆栈溢出解决方案,例如: Menu->Tools->Kotlin->将kotlin反编译到java 菜单>工具>Kotlin>显示Kotlin字节码 单击“反编译”按钮 复制java代码 并且总是禁用“反编译”按钮。
问题内容: 我的项目中有以下抽象的通用数据持有人(简化): 与一起,其中包含: 其背后的想法是能够定义一组变量,这些变量以 所谓的“状态” 实现该变量,如下所示: 然后,将这些变量添加到的实例中,该实例又被许多“状态”或“进程”共享。然后可以通过不同的状态更改an的值,然后在需要时由原始状态检索。一种共享内存模型。 这个概念已经运行了好多年(是的,这是遗留的),但是我们最近开始转向Java 8,即
我写了下面提到的一个简单的java程序。不幸的是,编译错误发生了。 在编译过程中,在命令提示符下会显示以下内容: c:\Java 它对我的任何程序都不起作用,即使是这个简单的程序也不行!这是为什么? 编辑: 现在我有: 而且它不起作用。为什么不起作用? 它说的和以前一样。 你对Java所说的。lang.String[]有效,但为什么不能呢?为什么我以前不需要穿上这些?
我有一个Kotlin项目,我想使用IntelliJ将其转换为Java代码。现在我读到我需要做的就是: 单击“反编译”按钮 复制java代码 所以我试着按照它去做,并且已经能够成功地查看Kotlin字节码--但是我想知道反编译按钮在哪里?可悲的是,我试着在谷歌里搜索它,却找不到它--也许我只是瞎了眼,这是显而易见的? 编辑: 当我按时,将显示此面板:
我有一个原型文件,用协议2语法编写。我正在使用协议3编译器编译这个原型文件。虽然它成功构建,但它在运行时显示以下错误。有人能帮我吗? [libprotobuf FATAL google/protobuf/extension\u set.cc:102]x.y.z.a类型的多个扩展注册,字段号200。在抛出“google::protobuf::FatalException”what():type“x.
问题内容: 我知道Java 7不能提供Java 7的运行时功能,但是由于 没有添加 新的字节码,因此新的字节码仅与非Java语言有关,我想知道转换Java会有多困难纯Java 6的7个源代码(新语句,菱形运算符)(即能够开始将源转换为Java 7而又不失去Java 6兼容性)。 有指针吗? 问题答案: 将Java 7 javac输出的.class文件标记为1.6.0版(即0x32) (根据http