Android room persistent: AppDatabase_Impl does not exist

pratik deshai

My app database class

@Database(entities = {Detail.class}, version = Constant.DATABASE_VERSION)
public abstract class AppDatabase extends RoomDatabase {

    private static AppDatabase INSTANCE;

    public abstract FavoritesDao favoritesDao();

    public static AppDatabase getAppDatabase(Context context) {
        if (INSTANCE == null) {
            INSTANCE =
                    Room.databaseBuilder(context.getApplicationContext(), AppDatabase.class, Constant.DATABASE).allowMainThreadQueries().build();

                    //Room.inMemoryDatabaseBuilder(context.getApplicationContext(),AppDatabase.class).allowMainThreadQueries().build();
        }
        return INSTANCE;
    }

    public static void destroyInstance() {
        INSTANCE = null;
    }
}

Gradle lib:

 compile "android.arch.persistence.room:runtime:+"   
 annotationProcessor "android.arch.persistence.room:compiler:+"

And when i ask for instance it will give this error, AppDatabase_Impl does not exist in my application class

public class APp extends Application {

    private boolean appRunning = false;

    @Override
    public void onCreate() {
        super.onCreate();
        AppDatabase.getAppDatabase(this); //--AppDatabase_Impl does not exist

    }   

}
RWIL

For those working with Kotlin, try changing annotationProcessor to kapt in the apps build.gradle

for example:

// Extensions = ViewModel + LiveData
implementation "android.arch.lifecycle:extensions:1.1.0"
kapt "android.arch.lifecycle:compiler:1.1.0"
// Room
implementation "android.arch.persistence.room:runtime:1.0.0"
kapt "android.arch.persistence.room:compiler:1.0.0"

also remember to add this plugin

apply plugin: 'kotlin-kapt'

to the top of the app level build.gradle file and do a clean and rebuild (according to https://codelabs.developers.google.com/codelabs/android-room-with-a-view/#6)

In Android Studio, if you get errors when you paste code or during the build process, select Build >Clean Project. Then select Build > Rebuild Project, and then build again.


UPDATE

If you have migrated to androidx

def room_version = "2.2.3" // check latest version from docs

implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version"

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

Why Android Room @Query LIKE is not returning data known to exist

From Java

Android Gradle Apache HttpClient does not exist?

From Java

AndroidX package android.support.design.R does not exist

From Dev

Maven compilation error for android Project "error: package R does not exist "

From Dev

Android sql column does not exist

From Dev

column '_id' does not exist using SQLite with android

From Dev

package com.google.android.maps does not exist Android Studio

From Dev

Error "package android.support.v7.app does not exist"

From Dev

error: package com.android.volley does not exist

From Dev

Android Studio: Resource file does not exist in library project

From Dev

Android error: package android.os does not exist

From Dev

Android build application: gradlew does not exist

From Dev

Android Studio Gradle Build error - specified for property 'manifest' does not exist

From Dev

How to implement getgrnam_r() in Android NDK? (Does not exist in bionic)

From Dev

Android SQLite table does not exist

From Dev

Android Studio keeps telling me method does not exist

From Dev

Android Databinding : package does not exist

From Dev

.iml file does not exist - Android Studio

From Dev

Android : missing package statement; Activity class does not exist

From Dev

Android Studio 2.1: error: package org.junit does not exist

From Dev

OpenCV for Android - does NativeCameraView still exist?

From Dev

Why Android Room @Query LIKE is not returning data known to exist

From Dev

Android room persistent: AppDatabase_Impl does not exist

From Dev

Android What is use of persistent?

From Dev

Does an Android package availability checking service exist?

From Dev

Activity class does not exist android

From Dev

does datepicker in android for year BC and AD exist

From Dev

Android Warning: Native component for "RCTMap" does not exist

From Dev

Does Android Application.getInstance always exist?

Related Related

  1. 1

    Why Android Room @Query LIKE is not returning data known to exist

  2. 2

    Android Gradle Apache HttpClient does not exist?

  3. 3

    AndroidX package android.support.design.R does not exist

  4. 4

    Maven compilation error for android Project "error: package R does not exist "

  5. 5

    Android sql column does not exist

  6. 6

    column '_id' does not exist using SQLite with android

  7. 7

    package com.google.android.maps does not exist Android Studio

  8. 8

    Error "package android.support.v7.app does not exist"

  9. 9

    error: package com.android.volley does not exist

  10. 10

    Android Studio: Resource file does not exist in library project

  11. 11

    Android error: package android.os does not exist

  12. 12

    Android build application: gradlew does not exist

  13. 13

    Android Studio Gradle Build error - specified for property 'manifest' does not exist

  14. 14

    How to implement getgrnam_r() in Android NDK? (Does not exist in bionic)

  15. 15

    Android SQLite table does not exist

  16. 16

    Android Studio keeps telling me method does not exist

  17. 17

    Android Databinding : package does not exist

  18. 18

    .iml file does not exist - Android Studio

  19. 19

    Android : missing package statement; Activity class does not exist

  20. 20

    Android Studio 2.1: error: package org.junit does not exist

  21. 21

    OpenCV for Android - does NativeCameraView still exist?

  22. 22

    Why Android Room @Query LIKE is not returning data known to exist

  23. 23

    Android room persistent: AppDatabase_Impl does not exist

  24. 24

    Android What is use of persistent?

  25. 25

    Does an Android package availability checking service exist?

  26. 26

    Activity class does not exist android

  27. 27

    does datepicker in android for year BC and AD exist

  28. 28

    Android Warning: Native component for "RCTMap" does not exist

  29. 29

    Does Android Application.getInstance always exist?

HotTag

Archive