(Kotlin) Backend Internal error: Exception during code generation

纵饮孤独 提交于 2019-11-30 17:36:47

I had the same problem, because I was using inconsistent version of Anko. With kotlin 1.3.x you have to use this v0.10.8 version of anko or newer.

Finally I Solved that Issue after Given 3 hours over it and Tried Almost everything

Reason : This Issue may be generate whenever you had taken any XML LAYOUT ID On Java File and you are not using it further. this Garbage XML ID on Java File leads to this Error Named As "Backend Internal error: Exception during code generation Android"

How Do Solve : well, you can find your garbage XML ID from That Error Itself... Just Copy paste your error on Notepad file and read it carefully , you will find XML ID NAME in near by file location in error line number , Thanks :)

This type of issue usually occurs when the Kotlin has a complex function definition. For example, declaring a class that inherits from AsyncTask. Best solution is try to pull some of this complexity out of the function call.

As for my case, java.lang.IllegalStateException: Backend Internal error went away when I moved some of the private functions and properties from a big class to other parts of the project. The class wasn't big initially, but I kept adding things without properly organizing.

I was getting the same error in my Android Project. The cause of the error was i taking my recyclerview's id from xml and just pasted the id in my code without apply any kind of property or calling any function on it.

I too was getting the same error in my Android Project. But in my project i was using when inside lambda and i try return not correct type in 4 line

    private val innChecker: (s: Editable?) -> String? = { s ->
        when {
            CheckUtils.checkZero(s.toString()) -> {
                if (!isBudget) textViewRed
                null
            }
            CheckUtils.checkAllZero(s.toString()) -> getString(R.string.not_all_zero)
            CheckUtils.checkStartZeroZero(s.toString()) -> getString(R.string.two_first_not_zero)
            CheckUtils.checkInn(s.toString(), isBudget, { textViewRedErrorKpp.isEnabled = it }, { textViewRedErrorKpp.setTextToEditText(it) }) -> {
                if (s?.length == 10) mPaymentRecipientPresenter?.tryFindInn()
                when {
                    isHardChecked -> {
                        null
                    }
                    else -> null
                }


            }
            else -> getString(R.string.enter_5_10_12_or_0)
        }

    }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!