Categories
discuss

Room The columns returned by the query does not have the fields

I keep a list of products in ‘Order’. When I try to get a list of products from the Room. I get the following error. But I made a TypeConvertor. What could be the error?

Order

   @Entity(tableName = Order.TABLE_NAME)
@JsonClass(generateAdapter = true)
data class Order(
    @PrimaryKey(autoGenerate = true)
    val id: Long,
    val isSendCheque: Int,
    val phone: String,
    val name: String,
    val comment: String? = "",
    val timeFrom: String,
    val timeTo: String,
    @TypeConverters(Converters::class)
    @ColumnInfo(name = "listProduct")
    var listProduct: List<Product>? = null,
    val publicOrderId: String
) {
    companion object {
        const val TABLE_NAME = "mau_order"
    }
}

Product

@Parcelize
@JsonClass(generateAdapter = true)
data class Product(
        @SerializedName("id")
        @PrimaryKey
        var id: Long = -1,
        @SerializedName("order_id") var orderId: Long = -1,
        @SerializedName("name") var name: String = "name product",
        @SerializedName("packaging") var packaging: String? = "1 кг",
        @SerializedName("path_image") var pathImage: String = "",
        @SerializedName("price") var price: Double = 0.0,
        @SerializedName("price_discount") var priceDiscount: Double = 0.0,
        @SerializedName("product_id") var productId: Int = -1,
        @SerializedName("quantity") var quantity: Double = 0.0,
        @SerializedName("units") var units: String = "ШТ",
        @SerializedName("created_at") var createdAt: String = "",
        @SerializedName("updated_at") var updatedAt: String = "",
        @SerializedName("brgew") var brgew: String = "",
        @SerializedName("gewei") var gewei: String = "кг"
) : Parcelable

OrdersDao

   @Dao
interface OrdersDao {
    /**
     * Inserts [orders] into the [Order.TABLE_NAME] table.
     * Duplicate values are replaced in the table.
     * @param orders Orders
     */
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertOrders(orders: List<Order>)
    /**
     * Inserts [orders] into the [Order.TABLE_NAME] table.
     * Duplicate values are replaced in the table.
     * @param orders Orders
     */
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertOrders(order: Order)

    /**
     * Deletes all the orders from the [Order.TABLE_NAME] table.
     */
    @Query("DELETE FROM ${Order.TABLE_NAME}")
    suspend fun deleteAllOrders()

    /**
     * Fetches the order from the [Order.TABLE_NAME] table whose id is [orderId].
     * @param orderId Unique ID of [Order]
     * @return [Flow] of [Order] from database table.
     */
    @Query("SELECT * FROM ${Order.TABLE_NAME} WHERE ID = :orderId")
    fun getOrderById(orderId: Long): LiveData<Order>

    //ERROR
    @Query("SELECT listProduct FROM ${Order.TABLE_NAME} WHERE ID = :orderId")
    fun getBasketById(orderId: Long): LiveData<Order>

    /**
     * Fetches all the orders from the [Order.TABLE_NAME] table.
     * @return [Flow]
     */
    @Query("SELECT * FROM ${Order.TABLE_NAME}")
    fun getAllOrders(): LiveData<List<Order>>
}

Converters

 @TypeConverter
fun stringToProductList(data: String?): MutableList<Product> {
    if (data == null) {
        return Collections.emptyList()
    }

    val listType = object : TypeToken<MutableList<Product>>() {

    }.type

    return gson.fromJson(data, listType)
}

@TypeConverter
fun ProductListToString(someObjects: MutableList<Product>?): String? {
    if (someObjects == null) {
        return null
    }
    return gson.toJson(someObjects)
}

Error

OrdersDao.java:53: error: The columns returned by the query does not have the fields [id,orderId,name,pathImage,price,priceDiscount,productId,quantity,units,createdAt,updatedAt,brgew,gewei] in com.vepe.navigation.model.entity.Product even though they are annotated as non-null or primitive. Columns returned by the query: [listProduct] public abstract java.util.List<com.vepe.navigation.model.entity.Product> getBasketHistoryFromOrderById(long orderId); Current JDK version 1.8.0_272-b10 has a bug (https://bugs.openjdk.java.net/browse/JDK-8007720) that prevents Room from being incremental. Consider using JDK 11+ or the embedded JDK shipped with Android Studio 3.5+.C:UsersmindStudioProjectsSarah_navigationProjectProjectAndroidappbuildtmpkapt3stubsdebugcomvepenavigationmodelentityProduct.java:8: error: Entity class must be annotated with @Entity

Help me please ! Thanks

UPDATE I tried to put the @Entity annotation I do not know whether they are necessary or not in my case And got the following error

error: The columns returned by the query does not have the fields [id,orderId,name,pathImage,price,priceDiscount,productId,quantity,units,createdAt,updatedAt,brgew,gewei] in com.vepe.navigation.model.entity.Product even though they are annotated as non-null or primitive. Columns returned by the query: [listProduct] public abstract kotlinx.coroutines.flow.Flow<java.util.List<com.vepe.navigation.model.entity.Product>> getBasketHistoryFromOrderById(long orderId); Current JDK version 1.8.0_272-b10 has a bug (https://bugs.openjdk.java.net/browse/JDK-8007720) that prevents Room from being incremental. Consider using JDK 11+ or the embedded JDK shipped with Android Studio 3.5+.C:UsersmindStudioProjectsSarah_navigationProjectProjectAndroidappbuildtmpkapt3stubsdebugcomvepenavigationdatalocaldaoOrdersDao.java:53: warning: The query returns some columns [listProduct] which are not used by com.vepe.navigation.model.entity.Product. You can use @ColumnInfo annotation on the fields to specify the mapping. com.vepe.navigation.model.entity.Product has some fields [id, orderId, name, packaging, pathImage, price, priceDiscount, productId, quantity, units, createdAt, updatedAt, brgew, gewei] which are not returned by the query. If they are not supposed to be read from the result, you can mark them with @Ignore annotation. You can suppress this warning by annotating the method with @SuppressWarnings(RoomWarnings.CURSOR_MISMATCH). Columns returned by the query: listProduct. Fields in com.vepe.navigation.model.entity.Product: id, orderId, name, packaging, pathImage, price, priceDiscount, productId, quantity, units, createdAt, updatedAt, brgew, gewei.

Answer

I came up with this way to solve the problem

In OrderService

@GET("orders/baskethistory/id/{id}")
suspend fun getBasketHistoryById(@Path("id") id: Long): Response<BasketHistory>

Data class for list of object

data class BasketHistory(
    @SerializedName("basketHistory") val listProduct : MutableList<Product>
)

Dao

@Query("SELECT id,listProduct FROM ${Order.TABLE_NAME} WHERE ID = :orderId")
fun getBasketById(orderId: Long): LiveData<BasketHistory>

Try it

Categories
discuss

Warning: ‘onCreateView’ always returns non-null type

Today I found this warning in all my fragments:

Warning:(45, 12) ‘onCreateView’ always returns non-null type

onCreateView:

override fun onCreateView(inflater: LayoutInflater,
    container: ViewGroup?,
    savedInstanceState: Bundle?): View? {
    ...
}

The question is, what has changed and why?

Android Studio version – 4.1.1.

Answer

this is Kotlin warning, probably new lint check for helping you producing better quality code

your method returns declared View?, but as we know in most cases this method shouldn’t return null View, so this ? (null safety) is redundant. just remove ?, declare your method returns just View (not null by default in Kotlin)

override fun onCreateView(inflater: LayoutInflater,
    container: ViewGroup?,
    savedInstanceState: Bundle?): View { // in here no "?"
    ...
}

btw. DOC is saying that this method may return null and Fragment behaves then just like some objects/data holder, without UI, just for proper retaining instance across Activitys lifecycle. but in that case dev won’t be overriding onCreateView at all

Categories
discuss

ViewModel has no zero argument constructor hilt Java

I am using hilt and am trying to get import my SessionManager into my AuthViewModel class.

When taking a look at Google’s documentation on hilt with ViewModel we can see they are able to inject ExampleRepository repository into the constructor of said ExampleViewModel

public class ExampleViewModel extends ViewModel {

  private final ExampleRepository repository;
  private final SavedStateHandle savedStateHandle;

  @ViewModelInject
  ExampleViewModel(
      ExampleRepository repository,
      @Assisted SavedStateHandle savedStateHandle)
    {
    this.repository = repository;
    this.savedStateHandle = savedStateHandle;
  }
  ...
}

and

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    exampleViewModel = new ViewModelProvider(this).get(ExampleViewModel.class);
  }

Whenever I try to do this with my project I keep on getting the error.

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.atchat.donation, PID: 11005
    java.lang.RuntimeException: Cannot create an instance of class com.atchat.donation.ui.auth.AuthViewModel
        at androidx.lifecycle.ViewModelProvider$NewInstanceFactory.create(ViewModelProvider.java:221)
        at androidx.lifecycle.ViewModelProvider$AndroidViewModelFactory.create(ViewModelProvider.java:278)
        at androidx.lifecycle.SavedStateViewModelFactory.create(SavedStateViewModelFactory.java:106)
        at androidx.hilt.lifecycle.HiltViewModelFactory.create(HiltViewModelFactory.java:74)
        at androidx.lifecycle.AbstractSavedStateViewModelFactory.create(AbstractSavedStateViewModelFactory.java:69)
        at androidx.lifecycle.ViewModelProvider.get(ViewModelProvider.java:185)
        at androidx.lifecycle.ViewModelProvider.get(ViewModelProvider.java:150)
        at com.atchat.donation.ui.auth.LoginFragment.onViewCreated(LoginFragment.java:97)
        at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:332)
        at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1199)
        at androidx.fragment.app.FragmentManager.addAddedFragments(FragmentManager.java:2236)
        at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:2009)
        at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1965)
        at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1861)
        at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:2641)
        at androidx.fragment.app.FragmentManager.dispatchActivityCreated(FragmentManager.java:2589)
        at androidx.fragment.app.Fragment.performActivityCreated(Fragment.java:2723)
        at androidx.fragment.app.FragmentStateManager.activityCreated(FragmentStateManager.java:346)
        at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1200)
        at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1368)
        at androidx.fragment.app.FragmentManager.moveFragmentToExpectedState(FragmentManager.java:1446)
        at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1509)
        at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:2637)
        at androidx.fragment.app.FragmentManager.dispatchActivityCreated(FragmentManager.java:2589)
        at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:247)
        at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:541)
        at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:210)
        at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1425)
        at android.app.Activity.performStart(Activity.java:7825)
        at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3294)
        at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:221)
        at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:201)
        at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:173)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
     Caused by: java.lang.InstantiationException: java.lang.Class<com.atchat.donation.ui.auth.AuthViewModel> has no zero argument constructor
        at java.lang.Class.newInstance(Native Method)
        at androidx.lifecycle.ViewModelProvider$NewInstanceFactory.create(ViewModelProvider.java:219)
        at androidx.lifecycle.ViewModelProvider$AndroidViewModelFactory.create(ViewModelProvider.java:278) 
        at androidx.lifecycle.SavedStateViewModelFactory.create(SavedStateViewModelFactory.java:106) 
        at androidx.hilt.lifecycle.HiltViewModelFactory.create(HiltViewModelFactory.java:74) 
        at androidx.lifecycle.AbstractSavedStateViewModelFactory.create(AbstractSavedStateViewModelFactory.java:69) 
        at androidx.lifecycle.ViewModelProvider.get(ViewModelProvider.java:185) 
        at androidx.lifecycle.ViewModelProvider.get(ViewModelProvider.java:150) 
        at com.atchat.donation.ui.auth.LoginFragment.onViewCreated(LoginFragment.java:97) 
        at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:332) 
        at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1199) 
        at androidx.fragment.app.FragmentManager.addAddedFragments(FragmentManager.java:2236) 
        at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:2009) 
        at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1965) 
        at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1861) 
        at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:2641) 
        at androidx.fragment.app.FragmentManager.dispatchActivityCreated(FragmentManager.java:2589) 
        at androidx.fragment.app.Fragment.performActivityCreated(Fragment.java:2723) 
        at androidx.fragment.app.FragmentStateManager.activityCreated(FragmentStateManager.java:346) 
        at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1200) 
        at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1368) 
        at androidx.fragment.app.FragmentManager.moveFragmentToExpectedState(FragmentManager.java:1446) 
        at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1509) 
        at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:2637) 
        at androidx.fragment.app.FragmentManager.dispatchActivityCreated(FragmentManager.java:2589) 
        at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:247) 
        at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:541) 
        at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:210) 
        at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1425) 
        at android.app.Activity.performStart(Activity.java:7825) 
        at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3294) 
        at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:221) 
        at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:201) 
        at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:173) 
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016) 
        at android.os.Handler.dispatchMessage(Handler.java:107) 
        at android.os.Looper.loop(Looper.java:214) 
        at android.app.ActivityThread.main(ActivityThread.java:7356) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930) 
I/Process: Sending signal. PID: 11005 SIG: 9

AuthViewModel

public class AuthViewModel extends ViewModel {

    private static final String TAG = "AuthViewModel";
    private final SessionManager sessionManager;

    @ViewModelInject
    public AuthViewModel(SessionManager sessionManager, @Assisted SavedStateHandle savedStateHandle){
        this.sessionManager = sessionManager;
    }
...
}

AppModule

@Module()
@InstallIn(SingletonComponent.class)
public class AppModule {

    @Provides
    public static SessionManager provideSessionManager(@ApplicationContext Context context, AccountRestService accountRestService){
        return new SessionManager(accountRestService, context);
    }
...
}

LoginFragment

@AndroidEntryPoint
public class LoginFragment extends Fragment implements View.OnClickListener {

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        viewModel = new ViewModelProvider(this).get(AuthViewModel.class);
        subscribeObservers();
        attemptSilentLogin();
    }
...
}

build.gradle (Module)

apply plugin: 'dagger.hilt.android.plugin'

dependencies {

    //Hilt
    implementation 'com.google.dagger:hilt-android:2.30-alpha'
    implementation 'androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha02'
    annotationProcessor 'com.google.dagger:hilt-android-compiler:2.30-alpha'
...
}

build.gradle (Project)

    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.1'
        classpath 'com.google.dagger:hilt-android-gradle-plugin:2.30-alpha'
    }

Answer

Your error message shows that the HiltViewModelFactory doesn’t have a binding for your specific AuthViewModel. It doesn’t because you haven’t included the additional annotationProcessor that is needed specifically for Hilt and Jetpack integrations – it is that extra androidx.hilt:hilt-compiler annotation processor that is responsible for reading the @ViewModelInject and generating the correct Hilt bindings.

dependencies {
    // Hilt
    implementation 'com.google.dagger:hilt-android:2.30-alpha'
    annotationProcessor 'com.google.dagger:hilt-android-compiler:2.30-alpha'

    // Hilt Jetpack Integrations
    implementation 'androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha02'
    annotationProcessor 'androidx.hilt:hilt-compiler:1.0.0-alpha02'
...
}
Categories
discuss

Android Studio Database Inspector always showing database as “closed”

I am trying to use Database Inspector in Android Studio. Why I run the app on the device, it inspector is always showing my application database (highlighted in the image) as “closed”.

Is there any fix for this or did I miss something during the setup?

enter image description here

Answer

UPD. last time I had this annoying issue Invalidate cache/Restart fixed this for me. Sigh

Running the app in Debug mode enter image description here (Win: Shift+F9 or Mac: Control+D) does the magic for me sometimes.

Not sure if this is a bug or not. The android documentation doesn’t mention on this, so I guess it should just work in normal mode, but for some reason doesn’t for me..

I use (Android Studio 4.2 beta 3). Property minSdkVersion set to 27.

I don’t use Room or any other ORM, just a few plain simplest queries.

The toggle ‘Keep database connection open’ doesn’t seem helping either.

In normal mode:

enter image description here

In Debug mode (what I want):

enter image description here

Noticeable, that it continuing to work (querying the database etc) even after I stopped the app running in Debug mode:

enter image description here

Categories
discuss

java.lang.RuntimeException: Hilt classes generated from @HiltAndroidTest are missing

I am trying to run a simple Robolectric test with Hilt.

@HiltAndroidTest
@Config(application = HiltTestApplication::class)
@RunWith(AndroidJUnit4::class)
class SplashActivityTest2 {

    @get:Rule
    var hiltRule = HiltAndroidRule(this)

    @Test
    fun fooTest() {
        val splashActivity = ActivityScenario.launch(SplashActivity::class.java)
    }
}

but when I try to run the test using Android Studio, am getting

java.lang.RuntimeException: Hilt classes generated from @HiltAndroidTest are missing. Check that you have annotated your test class with @HiltAndroidTest and that the processor is running over your test

Here’s the full stacktrace.

[Robolectric] com.theapache64.nemo.feature.splash.SplashActivityTest2.fooTest: sdk=28; resources=BINARY
Called loadFromPath(/system/framework/framework-res.apk, true); mode=binary sdk=28

java.lang.RuntimeException: Hilt classes generated from @HiltAndroidTest are missing. Check that you have annotated your test class with @HiltAndroidTest and that the processor is running over your test

    at dagger.hilt.android.internal.testing.TestApplicationComponentManager.<init>(TestApplicationComponentManager.java:68)
    at dagger.hilt.android.testing.HiltTestApplication.attachBaseContext(HiltTestApplication.java:39)
    at android.app.Application.attach(Application.java:212)
    at org.robolectric.util.ReflectionHelpers.callInstanceMethod(ReflectionHelpers.java:283)
    at org.robolectric.shadows.ShadowApplication.callAttach(ShadowApplication.java:79)
    at org.robolectric.android.internal.AndroidTestEnvironment.installAndCreateApplication(AndroidTestEnvironment.java:250)
    at org.robolectric.android.internal.AndroidTestEnvironment.setUpApplicationState(AndroidTestEnvironment.java:169)
    at org.robolectric.RobolectricTestRunner.beforeTest(RobolectricTestRunner.java:301)
    at org.robolectric.internal.SandboxTestRunner$2.lambda$evaluate$0(SandboxTestRunner.java:243)
    at org.robolectric.internal.bytecode.Sandbox.lambda$runOnMainThread$0(Sandbox.java:89)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassNotFoundException: dagger.hilt.android.internal.testing.TestComponentDataSupplierImpl
    at org.robolectric.internal.bytecode.SandboxClassLoader.getByteCode(SandboxClassLoader.java:164)
    at org.robolectric.internal.bytecode.SandboxClassLoader.maybeInstrumentClass(SandboxClassLoader.java:119)
    at org.robolectric.internal.bytecode.SandboxClassLoader.lambda$findClass$0(SandboxClassLoader.java:112)
    at org.robolectric.util.PerfStatsCollector.measure(PerfStatsCollector.java:53)
    at org.robolectric.internal.bytecode.SandboxClassLoader.findClass(SandboxClassLoader.java:111)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:419)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:352)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:264)
    at dagger.hilt.android.internal.testing.TestApplicationComponentManager.<init>(TestApplicationComponentManager.java:58)
    at dagger.hilt.android.testing.HiltTestApplication.attachBaseContext(HiltTestApplication.java:39)
    at android.app.Application.$$robo$$android_app_Application$attach(Application.java:212)
    at android.app.Application.attach(Application.java)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    ... 11 more


Process finished with exit code 255

Here’s my app/build.gradle

The same file with pure instrumentationTest (androidTest) works though.

Answer

You have missed this

kaptTest 'com.google.dagger:hilt-android-compiler:2.28-alpha'

from your dependencies..

source : https://developer.android.com/training/dependency-injection/hilt-testing

dependencies {
    // For Robolectric tests.
    testImplementation 'com.google.dagger:hilt-android-testing:2.28-alpha'
    // ...with Kotlin.
    👉👉👉👉👉 kaptTest 'com.google.dagger:hilt-android-compiler:2.28-alpha'
    // ...with Java.
    testAnnotationProcessor 'com.google.dagger:hilt-android-compiler:2.28-alpha'

    // For instrumented tests.
    androidTestImplementation 'com.google.dagger:hilt-android-testing:2.28-alpha'
    // ...with Kotlin.
    kaptAndroidTest 'com.google.dagger:hilt-android-compiler:2.28-alpha'
    // ...with Java.
    androidTestAnnotationProcessor 'com.google.dagger:hilt-android-compiler:2.28-alpha'
}
Source: stackoverflow
Text is available under the Creative Commons Attribution-ShareAlike License; additional terms may apply. By using this site, you agree to the Privacy Policy, and Copyright Policy. Content is available under CC BY-SA 3.0 unless otherwise noted. The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 © No Copyrights, All Questions are retrived from public domain..