How to solve 'Unresolved reference: arch' from "import android.arch.lifecycle"?

In a Kotlin file, I have an 'Unresolved reference: arch'.

import android.arch.lifecycle.Lifecycle
import android.arch.lifecycle.LifecycleObserver
import android.arch.lifecycle.OnLifecycleEvent

I have no experience in programming but I wanted to get started and learn by doing. I am trying to replicate an Android app from this article:

I have Android Studio 3.3, Kotlin compiler 1.3 and Gradle 4.10.1.

I have read several threads with similar problems and I have tried: 1) Clean, Rebuild, Sync with Gradle 2) Restart computer 3) Invalidate caches and restart AS 4) Delete .idea and restart the project 5) Look for any discrepancies in plugins but to my best of knowledge I have not found them, everything is in the latest stable version.

My project build.gradle:

buildscript {
ext.kotlin_version = '1.3.20'
repositories {

dependencies {
    classpath ''
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    classpath ''

My app build.gradle:

apply plugin: ''
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId ""
        minSdkVersion 21
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), ''
    productFlavors {
dependencies {
    implementation ''
    implementation ''
    implementation 'android.arch.lifecycle:extensions:1.1.1'
    implementation 'com.otaliastudios:cameraview:1.5.1'
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
    implementation 'androidx.core:core-ktx:1.1.0-alpha03'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
apply plugin: ''

It should run properly but instead build is failed

Execution failed for task ':app:compileDebugKotlin'.

Log points to this 'Unresolved reference: arch' and nothing else.


  • You're using androidx artifacts, therefore the classes that used to be in android.arch.lifecycle are now in androidx.lifecycle as per the Migrating to AndroidX documentation.