I created an Android Project with Kotlin. I selected empty compose at start and want to…
- User
I created an Android Project with Kotlin. I selected empty compose at start and want to use jetpack compose in the project. I want to use Mvvm, i created my packages for Interface -> inside the Interface package i created BottomBar package. I also have a different package which is Navigation. First i want to create a bottom navigation bar with jetpack compose in the app. I didn't add any dependencies yet either.How can i create a bottom navigation bar with 2 icons. Can you help me to create
- Assistant
- User
- Assistant
- User
import androidx.activity.compose.setContent import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import androidx.compose.foundation.layout.Column import androidx.compose.material.MaterialTheme import androidx.compose.material.Surface import androidx.compose.ui.platform.ComposeView import com.example.appcentdeezermusicapp.Interface.BottomBar.BottomNavigationBar
class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContent { Surface(color = MaterialTheme.colors.background) { Column { // Your screen content goes here } BottomNavigationBar() // Add the BottomNavigationBar here } } } }->errors -> Unresolved reference: appcompat:2,Unresolved reference: AppCompatActivity:10,'onCreate' overrides nothing:11,Unresolved reference: onCreate:12Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:public fun ComponentActivity.setContent(parent: CompositionContext? = ..., content: () -> Unit): Unit defined in androidx.activity.compose:13. Fix the errors and explain to me , also can you explain why we used AppCompatActivity because when i first created the app it was a different type
- Assistant
It seems that there is still an unresolved reference issue related to
AppCompatActivity. This issue can be caused by a missing dependency or the incorrect AndroidX version being used. First, please make sure you have implemented the required dependencies for AppCompat in yourapp/build.gradlefile:gradledependencies { // ... implementation 'androidx.appcompat:appcompat:<version>' // ... }Replace
<version>with the latest or your preferred version. It should automatically update the version to the latest compatible version to match your compileSdk/API level. A recommended version is1.3.1at the time of writing.