Jetpack Compose App doesn't launch on AVD

Viewed 670

I've written a sample using Jetpack Compose then whenever i try to Install it on an AVD, gradle builds the Project Successfully but the Built App doesn't launch. Everything About the Tools and Codes is ok, even Preview shows UI fine, if i Build APK and Install it myself manually then the app will install and correctly. in other words Android Studio doesn't install the App on AVD Automatically.

Android Studio = 4.2 Canary 10 | compose = 1.0.0-alpha02 | kotlin = 1.4.0 | gradle plugin = 4.2.0-alpha10 | gradle = 6.6.1

2 Answers

Make sure that android:exported flag for your launch activity in AndroidManifest is set to true

I had the same issue, but what worked for me was running it from the preview. Once you have a connected device, hitting the little run image(with a green play icon) on the top right corner of the preview pane will launch on the device or emulator. If you can't see this icon, scroll the preview pane all the way to the right.

screenshot of preview button to run app on device or emulator

However, to run your app using the normal run button on android studio, you need to make sure that your setContent{ } block inside onCreate is calling your Composable functions you declared earlier. This was the missing link for me as well.

Related