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: https://heartbeat.fritz.ai/creating-an-android-app-with-snapchat-style-filters-in-7-steps-using-firebases-ml-kit-e79946e99688
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 {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.2.0'
My app build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.zqc.ml.nautilus"
minSdkVersion 21
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
implementation 'com.google.firebase:firebase-core:16.0.6'
implementation 'com.google.firebase:firebase-ml-vision:18.0.2'
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: 'com.google.gms.google-services'
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.