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.

Field must be either non-private or provide a getter and setter method

See original GitHub issue

In my Kotlin project I have only three fragments using Android-State. Each of them has three properties to save and restore. Some of them are like this

@State lateinit var mVariable: SomethingParcelable

The others are Strings and Booleans (all variables are called mSomething). None of them is private. Nevertheless I obtain this error:

Error:Field must be either non-private or provide a getter and setter method
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

I can’t say which of my variables is causing this issue, but it seems to be a bug.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
long1eucommented, Aug 2, 2017

Yes. When I removed the internal modifier, it was all good.

0reactions
GrahamBorlandcommented, Feb 2, 2018

@vRallev Still happens with 1.2.0. I’ll try to isolate a repro case.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Advantage of set and get methods vs public variable [duplicate]
there are much more advantages: getters and setter can have validation in them, fields can't; using getter you can get subclass of wanted...
Read more >
Why getter and setter are better than public fields in Java ...
Shall I use getter and setter method or public field, is a classical doubt in a Java programers mind. I advise against public...
Read more >
Getters and Setters Methods in Java - CodeGym
First, all instance variables (fields) must be marked with the private modifier. Private is the strictest access modifier in Java.
Read more >
Why Should I Write Getters and Setters? - DZone
If you make a field public, it means you provide direct access to the caller. Then, the caller can do anything with your...
Read more >
Never Write a Getter or Setter in Java Again - YouTube
Use this to never have to write or even SEE a getter or setter in your Java programs ever again.Hate how much clutter...
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