迁移到 Jetpack 撰写错误:不允许未绑定的符号 [英] Migrate to Jetpack compose error: Unbound symbols not allowed

查看:44
本文介绍了迁移到 Jetpack 撰写错误:不允许未绑定的符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想迁移我现有的项目以部分使用 Jetpack compose.
所以我使用 Android studio 4.2-canary9 打开它并添加了一个 compose 活动,以便 Android studio 添加所需的配置.

I wanted to migrate my existing project to partially use Jetpack compose for it.
So I opened it using Android studio 4.2-canary9 and added a compose activity so that Android studio adds needed configurations needed.

当我尝试运行该项目时,它给了我一个错误:

When I tried to run the project it gave me an error:

e: java.lang.AssertionError: Unbound symbols not allowed

使用 Run with --stacktrace 我向我抛出了这个堆栈跟踪:

Using Run with --stacktrace I have this stacktrace thrown at me:

e: java.lang.AssertionError: Unbound symbols not allowed
    Unbound public symbol for public kotlinx.android.synthetic.main.activity_main/state.<get-state>|-5663767092261428579[0]
    Unbound public symbol for public kotlinx.android.synthetic.main.activity_main/stateContainer.<get-stateContainer>|-4335442114828357571[0]
    Unbound public symbol for public kotlinx.android.synthetic.main.activity_main/list.<get-list>|9139041782698166288[0]
    at org.jetbrains.kotlin.psi2ir.Psi2IrTranslator.generateModuleFragment(Psi2IrTranslator.kt:96)
    at org.jetbrains.kotlin.backend.jvm.JvmBackendFacade.doGenerateFiles(JvmBackendFacade.kt:87)
    at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.generateModule(JvmIrCodegenFactory.kt:40)
    at org.jetbrains.kotlin.codegen.KotlinCodegenFacade.compileCorrectFiles(KotlinCodegenFacade.java:35)
    at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.generate(KotlinToJVMBytecodeCompiler.kt:616)
    at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:203)
    at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:164)
    at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:51)
    at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:86)
    at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:44)
    at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:98)
    at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:346)
    at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:102)
    at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileIncrementally(IncrementalCompilerRunner.kt:240)
    at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.access$compileIncrementally(IncrementalCompilerRunner.kt:39)
    at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner$compile$2.invoke(IncrementalCompilerRunner.kt:81)
    at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compile(IncrementalCompilerRunner.kt:93)
    at org.jetbrains.kotlin.daemon.CompileServiceImplBase.execIncrementalCompiler(CompileServiceImpl.kt:601)
    at org.jetbrains.kotlin.daemon.CompileServiceImplBase.access$execIncrementalCompiler(CompileServiceImpl.kt:93)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1633)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:359)
    at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
    at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
    at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562)
    at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796)
    at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:677)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:676)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:834)

第一条路线提到了 activity_main 这是一个不是使用 compose 制作的活动.它指的是Kotlin android extensions,用于替换findViewById(state 是一个TextView ID)

The first route mentions activity_main which is an activity not made using compose. It refers to Kotlin android extensions which is used to replace findViewById (state is a TextView ID)

Unbound public symbol for public kotlinx.android.synthetic.main.activity_main/state.<get-state>|-5663767092261428579[0]

以下是一些配置:

  • 撰写:1.0.0-alpha02 &1.0.0-alpha04
  • kotlin:1.4.0 &1.4.10
  • android-gradle-plugin:4.2.0-alpha09 &4.2.0-alpha13
  • kotlin-stdlib:jdk8 和 jdk7
  • compose: 1.0.0-alpha02 & 1.0.0-alpha04
  • kotlin: 1.4.0 & 1.4.10
  • android-gradle-plugin: 4.2.0-alpha09 & 4.2.0-alpha13
  • kotlin-stdlib: either jdk8 and jdk7

提前致谢

推荐答案

我遇到了同样的问题.作为一种解决方法,我用 ViewBinding 替换了所有 Kotlin 合成.在我做完之后,一切都奏效了.

I had the same problem. As a workaround, I replaced all Kotlin synthetic with ViewBinding. After I did it everything worked.

这篇关于迁移到 Jetpack 撰写错误:不允许未绑定的符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆