error: cannot find symbol

Ошибка появилась после добавления базы данных.

D:\AndroidStudioProjects\MoviesKotlin\app\build\tmp\kapt3\stubs\debug\com\artelio\movieskotlin\adapter\MoviesAdapter.java:10: error: cannot find symbol
    private java.util.List<Movie> movies;
                           ^
  symbol:   class Movie
  location: class MoviesAdapterD:\AndroidStudioProjects\MoviesKotlin\app\build\tmp\kapt3\stubs\debug\com\artelio\movieskotlin\adapter\MoviesAdapter.java:22: error: cannot find symbol
    public final java.util.List<Movie> getMovies() {
                                ^
  symbol:   class Movie
  location: class MoviesAdapterD:\AndroidStudioProjects\MoviesKotlin\app\build\tmp\kapt3\stubs\debug\com\artelio\movieskotlin\adapter\MoviesAdapter.java:27: error: cannot find symbol
    java.util.List<Movie> value) {
                   ^
  symbol:   class Movie
  location: class MoviesAdapterD:\AndroidStudioProjects\MoviesKotlin\app\build\tmp\kapt3\stubs\debug\com\artelio\movieskotlin\api\ApiService.java:10: error: cannot find symbol
    public abstract io.reactivex.Observable<Result> getMovies(@org.jetbrains.annotations.NotNull()
                                            ^
  symbol:   class Result
  location: interface ApiServiceD:\AndroidStudioProjects\MoviesKotlin\app\build\tmp\kapt3\stubs\debug\com\artelio\movieskotlin\data\MovieDao.java:10: error: cannot find symbol
    public abstract androidx.lifecycle.LiveData<java.util.List<Movie>> getAllMovies();
                                                               ^
  symbol:   class Movie
  location: interface MovieDaoD:\AndroidStudioProjects\MoviesKotlin\app\build\tmp\kapt3\stubs\debug\com\artelio\movieskotlin\data\MovieDao.java:14: error: cannot find symbol
    public abstract Movie getMovieByID(int movieID);
                    ^
  symbol:   class Movie
  location: interface MovieDaoD:\AndroidStudioProjects\MoviesKotlin\app\build\tmp\kapt3\stubs\debug\com\artelio\movieskotlin\data\MovieDao.java:21: error: cannot find symbol
    java.util.List<Movie> movies);
                   ^
  symbol:   class Movie
  location: interface MovieDaoD:\AndroidStudioProjects\MoviesKotlin\app\build\tmp\kapt3\stubs\debug\com\artelio\movieskotlin\data\MovieDao.java:25: error: cannot find symbol
    Movie movie);
    ^
  symbol:   class Movie
  location: interface MovieDaoD:\AndroidStudioProjects\MoviesKotlin\app\build\tmp\kapt3\stubs\debug\com\artelio\movieskotlin\data\MovieDao.java:29: error: cannot find symbol
    Movie movie);
    ^
  symbol:   class Movie
  location: interface MovieDaoD:\AndroidStudioProjects\MoviesKotlin\app\build\tmp\kapt3\stubs\debug\com\artelio\movieskotlin\view\MainViewModel.java:9: error: cannot find symbol
    private androidx.lifecycle.LiveData<java.util.List<Movie>> movies;
                                                       ^
  symbol:   class Movie
  location: class MainViewModelD:\AndroidStudioProjects\MoviesKotlin\app\build\tmp\kapt3\stubs\debug\com\artelio\movieskotlin\view\MainViewModel.java:12: error: cannot find symbol
    public final androidx.lifecycle.LiveData<java.util.List<Movie>> getMovies() {
                                                            ^
  symbol:   class Movie
  location: class MainViewModelD:\AndroidStudioProjects\MoviesKotlin\app\build\tmp\kapt3\stubs\debug\com\artelio\movieskotlin\view\MainViewModel.java:17: error: cannot find symbol
    androidx.lifecycle.LiveData<java.util.List<Movie>> p0) {
                                               ^
  symbol:   class Movie
  location: class MainViewModelD:\AndroidStudioProjects\MoviesKotlin\app\build\tmp\kapt3\stubs\debug\com\artelio\movieskotlin\view\MainViewModel.java:21: error: cannot find symbol
    java.util.List<Movie> movies) {
                   ^
  symbol:   class Movie
  location: class MainViewModelD:\AndroidStudioProjects\MoviesKotlin\app\build\tmp\kapt3\stubs\debug\com\artelio\movieskotlin\view\MainViewModel.java:33: error: cannot find symbol
    public static final class InsertMoviesTask extends android.os.AsyncTask<java.util.List<? extends Movie>, kotlin.Unit, kotlin.Unit> {
                                                                                                     ^
  symbol:   class Movie
  location: class MainViewModelD:\AndroidStudioProjects\MoviesKotlin\app\build\tmp\kapt3\stubs\debug\com\artelio\movieskotlin\view\MainViewModel.java:37: error: cannot find symbol
        java.util.List<Movie>... p0) {
                       ^
  symbol:   class Movie
  location: class InsertMoviesTaskD:\AndroidStudioProjects\MoviesKotlin\app\build\tmp\kapt3\stubs\debug\com\artelio\movieskotlin\data\MovieDatabase.java:5: error: cannot find symbol

Код адаптера:

import Movie
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import androidx.recyclerview.widget.RecyclerView
import com.artelio.movieskotlin.R
import com.squareup.picasso.Picasso

private const val BASE_POSTER_URL = "https://image.tmdb.org/t/p/"
private const val SMALL_POSTER_SIZE = "w185"

class MoviesAdapter : RecyclerView.Adapter<MoviesAdapter.MoviesViewHolder>() {

    var endOfPage: EndOfPage? = null

    var movies: List<Movie> = ArrayList()
    set(value){
        field = value
        notifyDataSetChanged()
    }

    class MoviesViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView){
        val smallPoster: ImageView = itemView.findViewById(R.id.imageViewSmallPoster)
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MoviesViewHolder {
        val view: View = LayoutInflater.from(parent.context).inflate(R.layout.image_item, parent, false)
        return MoviesViewHolder(view)
    }

    override fun getItemCount(): Int {
        return movies.size
    }

    override fun onBindViewHolder(holder: MoviesViewHolder, position: Int) {
        val movie = movies[position]
        Picasso.get().load(BASE_POSTER_URL + SMALL_POSTER_SIZE + movie.poster_path).into(holder.smallPoster)
        if(position == 16){
            endOfPage?.nextPage()
        }
    }

}

interface EndOfPage {
    fun nextPage()
}

База данных:

import Movie
import android.content.Context
import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase

@Database(entities = [Movie::class], version = 1, exportSchema = false)
abstract class MovieDatabase : RoomDatabase(){
    abstract fun movieDao(): MovieDao?
    companion object{
        private var database: MovieDatabase? = null
        private const val DB_NAME: String = "movies.db"
        private val LOCK: Any = Any()
        fun getInstance(context: Context): MovieDatabase? {
            synchronized(LOCK){
                if(database == null){
                    database = Room.databaseBuilder(context, MovieDatabase::class.java, DB_NAME).fallbackToDestructiveMigration().build()
                }
                return database
            }
        }
    }
}

Dao:

import Movie
import androidx.lifecycle.LiveData
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.Query

interface MovieDao {
    @Query("SELECT * FROM movies")
    fun getAllMovies(): LiveData<List<Movie>>

    @Query("SELECT * FROM movies WHERE id == :movieID")
    fun getMovieByID(movieID: Int): Movie?

    @Query("DELETE FROM movies")
    fun deleteAllMovies()

    @Insert
    fun insertMovies(movies: List<Movie>)

   @Insert
    fun insertMovie(movie: Movie)

    @Delete
    fun deleteMovie(movie: Movie)
}

Класс Movie:

import androidx.room.Entity
import androidx.room.PrimaryKey
import com.google.gson.annotations.SerializedName
@Entity(tableName = "movies")
data class Movie (
    @SerializedName("popularity") val popularity : Double,
    @SerializedName("vote_count") val vote_count : Int,
    @SerializedName("video") val video : Boolean,
    @SerializedName("poster_path") val poster_path : String,
    @SerializedName("id") val id : Int,
    @SerializedName("adult") val adult : Boolean,
    @SerializedName("backdrop_path") val backdrop_path : String,
    @SerializedName("original_language") val original_language : String,
    @SerializedName("original_title") val original_title : String,
    @SerializedName("title") val title : String,
    @SerializedName("vote_average") val vote_average : Double,
    @SerializedName("overview") val overview : String,
    @SerializedName("release_date") val release_date : String
){
    @PrimaryKey(autoGenerate = true)
    val uniqId: Int = 0
}

Класс Result:

import com.google.gson.annotations.SerializedName

data class Result (
    @SerializedName("page") val page : Int,
    @SerializedName("total_results") val total_results : Int,
    @SerializedName("total_pages") val total_pages : Int,
    @SerializedName("results") val results : List<Movie>
)

gradle:app:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.1"

    defaultConfig {
        applicationId "com.artelio.movieskotlin"
        minSdkVersion 24
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "org.jetbrains.kotlin:kotlin-stdlib:1.4.0"
    implementation 'androidx.core:core-ktx:1.3.1'
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.1.0'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
    testImplementation 'junit:junit:4.13'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation 'com.squareup.picasso:picasso:2.71828'

    def lifecycle_version = "2.2.0"
    def arch_version = "2.1.0"

    // ViewModel
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
    // LiveData
    implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
    // Lifecycles only (without ViewModel or LiveData)
    implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version"

    // Saved state module for ViewModel
    implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:$lifecycle_version"

    // Annotation processor
    kapt "androidx.lifecycle:lifecycle-compiler:$lifecycle_version"
    // alternately - if using Java8, use the following instead of lifecycle-compiler
    implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"

    // optional - helpers for implementing LifecycleOwner in a Service
    implementation "androidx.lifecycle:lifecycle-service:$lifecycle_version"

    // optional - ProcessLifecycleOwner provides a lifecycle for the whole application process
    implementation "androidx.lifecycle:lifecycle-process:$lifecycle_version"

    // optional - ReactiveStreams support for LiveData
    implementation "androidx.lifecycle:lifecycle-reactivestreams-ktx:$lifecycle_version"

    implementation "android.arch.persistence.room:runtime:1.1.1"
    kapt "android.arch.persistence.room:compiler:1.1.1"

    implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
    implementation 'io.reactivex.rxjava2:rxjava:2.2.9'
    implementation 'com.squareup.retrofit2:retrofit:2.9.0'
    implementation 'com.squareup.retrofit2:adapter-rxjava:2.9.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
    implementation 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
    implementation 'com.google.code.gson:gson:2.8.6'

}

Ответы (0 шт):