Questions tagged [kotlin-lateinit]

78 questions
0
votes
1 answer

xception in thread "Thread-6" kotlin.UninitializedPropertyAccessException: lateinit property has not been initialized

Hi guys I am developing an application with Spring Boot, Although I am having some problems initializing a JPA repository in a thread generating the following error Exception in thread "Thread-6" kotlin.UninitializedPropertyAccessException: lateinit…
Angel
  • 15
  • 3
0
votes
2 answers

Kotin lateinit Var Not initialized - Android Studio

I am working on a simple contact app that stores the contact's name, email, and number. Language: Kotlin Architecture: MVVM But I am getting an error: lateinit property addContactViewModel has not been initialized Activity: class AddContact :…
Haris
  • 68
  • 9
0
votes
1 answer

@Inject lateinit property has not been initialized Dagger2

I try to use Dagger2 to my project. I have a Firebase service and a class called SyncFactory that makes a specific request. When i get a call from Firebase i make my request. I have created a Mangers Module @Module(includes =…
james04
  • 1,580
  • 2
  • 20
  • 46
0
votes
2 answers

I am using sqlite incorrectly in this kotlin class

I started learning kotlin recently, and I am trying to implement a database using SQLite. When I try using the functions the app crashes. I don't know how to find the error log so I have added the functions I made and where the functions are…
0
votes
2 answers

How to find is a lateinit var has been initialized via Reflection?

I want to find out via reflection if lateinit property of an object has been initialized. How do I got about doing that? Getting the property and checking non-null results in UninitializedPropertyAccessException fun Any.isAnyEntityInitialized ()…
0
votes
2 answers

lateinit property onItemClickCallback has not been initialized

I'm newbie on android and kotlin. I'm making onclick listener for my cardViewAdapter using interface so i can override its callback from my activity. But I get the error "lateinit property onItemClick has not been initialized" when running it on…
0
votes
1 answer

How to recreate activity

I have activity and fragment. I get shared pref. in my fragment: private var dManager: DataManager?=null private lateinit var sp: SharedPreferences override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, …
Dima
  • 1,189
  • 1
  • 8
  • 12
0
votes
2 answers

lateinit property dManager has not been initialized

I have a variable in my fragment class: private lateinit var dManager: DataManager And I'm initializing it before the first using here: override fun onResume() { super.onResume() dManager = MyApp.gManager.getDataManager(sp,level,test) …
Dima
  • 1,189
  • 1
  • 8
  • 12
0
votes
1 answer

How to fix "lateinit property YYY has not been initialized"

I have a class that makes bluetooth connection and gets a PID from an OBD bluetooth dongle that its connected in the car. But when calling the method for getting RPM then I have an Exception about not initialazing that property. class…
Thodoris
  • 55
  • 2
  • 10
0
votes
1 answer

In kotlin for a lateinit why it has to use "this::"

The doc shows sample for checking whether a lateinit var has been initialized: println("isInitialized before assignment: " + this::lateinitVar.isInitialized) lateinitVar = "value" println("isInitialized after assignment: " +…
lannyf
  • 9,865
  • 12
  • 70
  • 152
0
votes
1 answer

Uninitialized exception while initializing "late init" property

I am not really sure if my case is just not possible with late init properties. But let me just ask :) I have an applicationController which is used in nearly every activity - so i created a BaseActivity The problem now is that when I want to get…
thovor
  • 3
  • 1
0
votes
0 answers

How to change Google map camera from a different fragment

Here's the scenario: 1) The starts off with FragmentA, which contains a Google Maps fragment, the camera is moved to the GPS location of the user 2) The user switches to FragmentB, in it there is a Place Autocomplete Fragment where i grab the…
Barcode
  • 930
  • 1
  • 13
  • 31
0
votes
2 answers

why doesn't lateinit work with the elvis operator, and how specifically is it different from optionals

Say I have the following class: class ExampleClass: OtherClass { lateinit var thing: Thing var thingOptional: Thing? = null fun exampleFun() { val innerThing = thing ?: Thing() val innerThing2 = thingOptional ?: Thing() } } Produces…
Abraham P
  • 15,029
  • 13
  • 58
  • 126
0
votes
1 answer

I cannot make userMapper.kt(interface) used in servicePackage when I using Mybatis

Although I had marked 'lateinit',it's still not initialized. It's one ghost bug,last night everything is OK,but today it's can't work,it's so tiredenter image description here
0
votes
1 answer

How to implement lateinit properly with custom class objects for use in onCreate() in android avoiding 'Property getter or setter expected' error

I am trying to implement the integration of a Dialogflow (previously api.ai) agent with my Android app, using Kotlin. I checked other Q&A about kotlin lateinit and the onCreate() lifecycle in Android is ideal for late-init implementations, to avoid…