https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
l

Lena Stepanova

05/28/2021, 3:09 PM
Hi everyone! I don't know if it has to do with KMM, but I can't build a multiplatfom project anymore, which was fine a month ago. I am using dataBinding in the android app and now getting Unresolved reference: generated and Unresolved reference: BR after
Copy code
> Task :androidApp:compileDebugKotlin FAILED
Does anyone know what's missing? There is also
Copy code
> Task :androidApp:kaptDebugKotlin
[WARN] Can't find annotation processor class android.databinding.annotationprocessor.ProcessDataBinding: javax/xml/bind/JAXBException
Also it builds and runs if I just Rebuild in AS. If I do ./gradlew clean build, then it fails Android build.gradle
Copy code
plugins {
  id("com.android.application")
  id("androidx.navigation.safeargs")
  kotlin("android")
  kotlin("android.extensions")
  kotlin("kapt")
  id("kotlin-android") 
} 
version = "1.0"

repositories {
  gradlePluginPortal()
  google()
  jcenter()
  mavenCentral()
}


dependencies {
  implementation(kotlin("stdlib-jdk7", org.jetbrains.kotlin.config.KotlinCompilerVersion.VERSION))
  implementation(project(":shared"))
  implementation(Deps.recyclerView)
  implementation(Deps.material_x)
  implementation(Deps.app_compat_x)
  implementation(Deps.core_ktx)
  implementation(Deps.Ktor.androidCore)
  implementation(Deps.constraintlayout)
  implementation(Deps.SqlDelight.runtimeJdk)
  implementation(Deps.SqlDelight.driverAndroid)
  implementation(Deps.Coroutines.common)
  implementation(Deps.Coroutines.android)
  implementation(Deps.multiplatformSettings)
  implementation(Deps.koinCore)
  implementation(Deps.lifecycle_extension)
  implementation(Deps.lifecycle_viewmodel)
  implementation(Deps.lifecycle_livedata)
  implementation(Deps.lifecycle_runtime)
  implementation (Deps.navigation_fragment)
  implementation (Deps.navigation_ui)
  implementation (Deps.drawer)
  implementation(Deps.legacySupport)
  testImplementation(Deps.junit)
}



android {
  compileSdkVersion(29)
  defaultConfig {
    applicationId = " "
    minSdkVersion(21)
    targetSdkVersion(29)
    versionCode = 11
    versionName = "2.0"
  }

  dataBinding {
    isEnabled = true
  }

  packagingOptions {
    exclude("META-INF/*.kotlin_module")
  }

  signingConfigs {
    create("release") {
      keyAlias = " "
      keyPassword = " "
      storeFile = file(" ")
      storePassword = " "
    }
  }

  buildTypes {
    getByName("release") {
      isMinifyEnabled = false
      proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "<http://proguard-rules.pro|proguard-rules.pro>")
      signingConfig = signingConfigs.getByName("release")
    }
  }

  compileOptions {
    sourceCompatibility = JavaVersion.VERSION_1_8
    targetCompatibility = JavaVersion.VERSION_1_8
  }

  kotlinOptions {
    jvmTarget = JavaVersion.VERSION_1_8.toString()
  }

  lintOptions {
    isWarningsAsErrors = true
    isAbortOnError = true
  }
}
k

kqr

05/28/2021, 6:35 PM
I guess you run it on jdk 9+
l

louiscad

05/28/2021, 6:47 PM
Which AGP version are you on? Did you try running the clean task alone, then running the build task alone? Running clean and build in the same Gradle build/invocation can cause problems with some plugins I think.
l

Lena Stepanova

06/16/2021, 9:32 AM
Hi all, sorry fo a late reply. Yes, I tried running clean and build separately, as well as other options. But now I have resolved the problem and the reason seems to be outdated dependencies and
Copy code
dataBinding {
    isEnabled = true
  }
Which had to be changed into
Copy code
buildFeatures {
    viewBinding = true
    dataBinding = true
}
I also replaced
Copy code
id("kotlin-android-extensions")
with
Copy code
id("kotlin-parcelize")
Now after upgrading to kotlin 1.5.10, as well as upgrading Android Studio to Artic Fox (2020.3.1) Beta 3 everything works as it should
11 Views