Migrate to Jetpack compose error: Unbound symbols not allowed

Cazimir Roman
Oct 21, 2020

Do you have the above mentioned error in Android Studio 4.2 Canary 13?

java.lang.AssertionError: Unbound symbols not allowed
Unbound public symbol for public kotlinx.android.synthetic.main.activity_main/coordinator.<get-coordinator>|928291878556573136[0

The reason for this error is that Jetpack Compose cannot be used alongside the normal synthetic imports for xml layouts:

EDIT: The issue has been solved in version 1.4.20 : https://github.com/JetBrains/kotlin/pull/3726

So, if you have imports like this one in your Activity and Fragments:

…you have 2 options to solve the problem:

  1. Replace the synthetic imports with normal data binding
  2. Update to Kotlin version 1.4.20-M2

The first option was not viable for me so I went for the second option.

Setting -> Languages & Framework

Choose Early Access Preview 1.4.x and make sure you have 1.4.20-M2 installed.

Afterwards you need to change the Kotlin gradle plugin to use version 1.4.20-M2 as well.

To make sure that the newest milestone version is visible you need to include the following maven repository dependency in the project build.gradle file.

buildscript {
ext.kotlin_version = "1.4.20-M2"
repositories {
google()
jcenter()
maven {
url "https://dl.bintray.com/kotlin/kotlin-eap/"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.0-alpha13'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.3.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

Before you go…If you found this article helpful, click the ❤️ or 👏 button below or share the article on Facebook so your friends can benefit from it too.

Happy coding!

--

--

Cazimir Roman

A curious developer with a passion for learning and creating innovative solutions to complex problems.