I have this blocking error that prevents me from launching my application. Obviously, the signature of this method requires generic types. I don't understand which ones I should use... maybe a version error in Android Studio? The internet hasn't helped me so far...
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
activityMainBinding = DataBindingUtil.setContentView(this, R.layout.activity_main) as ActivityMainBinding
supportActionBar?.hide()
fusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(this)
activityMainBinding.rlMainLayout.visibility = View.GONE
getCurrentLocation()
activityMainBinding.etGetCityName.setOnEditorActionListener( { v, actionId, KeyEvent ->
if(actionId==EditorInfo.IME_ACTION_SEARCH){
getCityWeather(activityMainBinding.etGetCityName.text.toString())
val view = this.currentFocus
if(view!=null){
val imm:InputMethodManager=getSystemService(INPUT_METHOD_SERVICE)as InputMethodManager
imm.hideSoftInputFromWindow(view.windowToken,0)
activityMainBinding.etGetCityName.clearFocus()
}
true
}else false
} )
}
the gradle file :
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}
android {
namespace 'master.kotlin.weather'
compileSdk 33
defaultConfig {
applicationId "master.kotlin.weather"
minSdk 21
targetSdk 33
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures{
dataBinding = true
viewBinding = true
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.8.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
implementation 'com.google.android.gms:play-services-location:21.0.1'
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
}
if anyone has the solution...
You should use this code to set the content view.
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
activityMainBinding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
// REST OF THE CODE
}
Feel free to ask if you need help with something else.