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.

lateinit property initialState has not been initialized

See original GitHub issue

Hi,

I encountered a problem with CircularProgressButton I wanted to try the behavior of my button, so I called startAnimation() in the onCreate() but I get this exception : lateinit property initialState has not been initialized If I call it after (like in an onClickListener) it works fine

As sample I used a simple project with an empty activity :

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        button.startAnimation()
    }
}
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
	xmlns:app="http://schemas.android.com/apk/res-auto"
	xmlns:tools="http://schemas.android.com/tools"
	android:layout_width="match_parent"
	android:layout_height="match_parent"
	tools:context=".MainActivity">

	<br.com.simplepass.loadingbutton.customViews.CircularProgressButton
		android:id="@+id/button"
		android:layout_width="match_parent"
		android:layout_height="wrap_content"
		android:text="Hello World!"
		app:layout_constraintBottom_toBottomOf="parent"
		app:layout_constraintLeft_toLeftOf="parent"
		app:layout_constraintRight_toRightOf="parent"
		app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

kotlin 1.3 AndroidX LoadingButtonAndroid 2.0.7

Best regards

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:7
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
leandroBorgesFerreiracommented, May 16, 2019

Use the version 2.1.3, this is fixed in that one =]

2reactions
flo5324commented, Feb 26, 2019

So, for those who have the same issue I found a workaround :

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        // This will manually initialize the 'initialState' field
        button.saveInitialState()

        button.startAnimation()
    }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

lateinit property has not been initialized - Stack Overflow
I'm using the latest version of butterknife library. The following is my Kotlin class: class MenuItemView : LinearLayout { @BindView(R.
Read more >
How to Check if a "lateinit" Variable Has Been Initialized or ...
You can check if the lateinit variable has been initialized or not before using it with the help of isInitialized() method. This method...
Read more >
lateinit Property in Kotlin - Suneet Agrawal
Accessing a lateinit property before it has been initialized throws a special exception that clearly identifies the property being accessed and the fact...
Read more >
Initializing lazy and lateinit variables in Kotlin - LogRocket Blog
Firstly, memory is not allocated to a lateinit property at the time of declaration. The initialization takes place later when you see fit....
Read more >
Kotlin Android Mvp + Dagger 2 Lateinit Property Presenter ...
Dagger2 Android DI lateinit property has not been initialized. 20200604 17:41 Kratos imported from Stackoverflow View { @Inject lateinit var presenter: ...
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