I'm creating a new Android project and I adding Dagger 2, but it fails with an error related to androidx
libraries.
After using a template from within Android Studio, I've added a few lines, kotlin-kapt
, and the dependencies for Dagger 2.
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
...
dependencies {
...
// Dagger
implementation 'com.google.dagger:dagger:2.16'
kapt 'com.google.dagger:dagger-compiler:2.16'
...
}
When trying to build the application, it fails with the following errors.
error: cannot find symbol
public final class MainActivityViewModel extends android.arch.lifecycle.ViewModel {
^
symbol: class ViewModel
location: package android.arch.lifecycle
error: cannot find symbol
private final androidx.lifecycle.MediatorLiveData
^
symbol: class MediatorLiveData
location: package androidx.lifecycle
error: cannot find symbol
private androidx.navigation.NavController navController;
^
symbol: class NavController
location: package androidx.navigation
...
I've tried with androidx
libraries, and the older libraries but both fail. If I removed the Dagger 2 dependencies it will build and run fine.
I'm currently using Android Studio 3.2 Canary 17.
Any idea what's going wrong?
Thanks.
from Cannot find symbol ViewModel with Dagger 2
No comments:
Post a Comment