I have to press "Run" twice or clean project before "Run" on Android Studio

Viewed 4308

So, I'm quite new to Android Studio but I have an issue: I program in Kotlin and when I change something in my code and press "Run" it just runs as it did before and ignoring the changes. If i press "Run" after that first try again it applies the changes. It also works, if I first hit "Buld/Clean Project".

What am I doing wrong? How can I make Android Studio to take the new code immediately?

Cheers.

1 Answers

Update

it seems to be that the issue is fixed in newer android studio version, currently i am working on android studio 4.2.1 and it is working fine even with allowing the parallel run feature.

Old Answer

After a long search, I found that the issue is in something called instant run when you rerun your code, to solve this issue in the older android studio you have to disable instant run by going to:

File -> Settings -> Build,Execution,Deployment -> Instant Run

and then disable it.

For me I am using the android studio +4.0.0 version so I opened:

Run -> Edit configurations... -> disable check box (Allow parallel run)*

It may slow your build a little but it better than running the app more than one time.

Related