Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 388
dalleaux Avatar asked Mar 24 '20 14:03

dalleaux


People also ask

Why can't I run my project in Android Studio?

Clean and then rebuild your project. Make your project (it should work by now) Check your dependencies in gradle. At the very end you can try invalidating the cache and restarting (Recommended)

What happens if project is clean Android studio?

Obviously, try to clean your project from android studio : “Build -> Clean Project”. This will clear your build folders. Clear the cache of Android Studio using “File -> Invalidate Caches / Restart” choose “Invalidate and restart option” and close Android Studio.

Does Android studio still have instant run?

Instant Run is currently available only in Android Studio 2.0, and higher. We will continue to improve the feature in subsequent releases.


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.

like image 124
Ahmed Happa Avatar answered Sep 27 '22 20:09

Ahmed Happa