When I normally I app run after building android studio throws this error.
at com.shayan.test.databinding.ActivityMainBinding.inflate(ActivityMainBinding.java:113)
E/AndroidRuntime: at com.shayan.test.MainActivity.onCreate(MainActivity.kt:14)
I think I forget something to do calling method or something
package com.shayan.test
package com.shayan.test
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import com.shayan.test.databinding.ActivityMainBinding
class MainActivity : AppCompatActivity() {
lateinit var binding: ActivityMainBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMainBinding.inflate(LayoutInflater.from(this))
(binding.root)
}
}
2
Answers
your using viewbinding.. setContentView is missing. and
change to
Full code for example
Try this methods :
2:
If this method does not help you then It’s not about the Gradle file. It is about the XML file.