question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@BindValue fields cannot be private.

See original GitHub issue

Hilt is generating my public @BindValue kotlin properties as private and complaining about it:

@HiltAndroidTest
@UninstallModules(
    AuthenticationStorageModule::class, 
)
@RunWith(AndroidJUnit4::class)
//@Config(application = HiltTestApplication::class)  // For Robolectric tests
class MainActivityInstrumentedTest {

    @get:Rule(order = 0) var hiltRule = HiltAndroidRule(this)
    @get:Rule(order = 1) var activityScenarioRule = activityScenarioRule<MainActivity>(null)

    @Before fun init() = hiltRule.inject()

    @BindValue 
    val ftueData = object : FirstTimeUserExperienceData {
        override var hasOnboardingBeenCompleted = false
        override var hasNotificationAllowed = false
        override var hasFindMyDeviceCompleted = false
    }

    @BindValue 
    val authenticationData = object : AuthenticationData {
        override var name = ""
        override var emailAdress = ""
    }

    @Test fun test() = runBlockingTest { }

}

below is the error from Hilt:

.../build/tmp/kapt3/stubs/debugAndroidTest/com/my/app/MainActivityInstrumentedTest.java:31: error: [Hilt]
    private final com.my.app.storage.FirstTimeUserExperienceData ftueData = null;
                                                                                 ^
  @BindValue fields cannot be private. Found: ftueData
  [Hilt] Processing did not complete. See error above for details.warning: File for type 

'com.my.app.MainActivityInstrumentedTest_HiltComponents' created in the last round will not be subject to annotation processing.
warning: File for type 'com.my.app.MainActivityInstrumentedTest_ComponentDataHolder' created in the last round will not be subject to annotation processing.
warning: File for type 'dagger.hilt.android.internal.testing.TestComponentDataSupplierImpl' created in the last round will not be subject to annotation processing.
warning: The following options were not recognized by any processor: '[dagger.fastInit, dagger.hilt.android.internal.disableAndroidSuperclassValidation, kapt.kotlin.generated]'
[WARN] Incremental annotation processing requested, but support is disabled because the following processors are not incremental: android.databinding.annotationprocessor.ProcessDataBinding (DYNAMIC).

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11

github_iconTop GitHub Comments

4reactions
bcorsocommented, Aug 11, 2020

Hi @Computr0n , for now I think either @BindValue lateinit var or @BindValue @JvmField val will work.

We do have plans to make this work with just @BindValue var, but we haven’t gotten to this yet.

2reactions
bcorsocommented, Aug 13, 2020

Thanks for the heads up on the documentation! That should be fixed now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Impossible to use BindValue in the SELECT field names?
It seems bindValue is adding quotes to my variable, which is fine in the ORDER BY, but creates problems in the fields i...
Read more >
PDOStatement::bindParam - Manual - PHP
Binds a PHP variable to a corresponding named or question mark placeholder in the SQL statement that was used to prepare the statement....
Read more >
Text Field - MudBlazor - Blazor Component Library
When you bind value types, the text field will not be empty even if the user hasn't entered a value yet because a...
Read more >
ASP.NET Core Blazor data binding - Microsoft Learn
Razor components provide data binding features with the @bind Razor directive attribute with a field, property, or Razor expression value.
Read more >
How do you use bind-value and bind-value:event on a custom ...
Couldn't find the FAQs you're looking for? Please submit your question and answer. Platform.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found