首页 > 解决方案 > 我必须在 Android Studio 上的“运行”之前按两次“运行”或清理项目

问题描述

所以,我对 Android Studio 很陌生,但我有一个问题:我在 Kotlin 中编程,当我更改代码中的某些内容并按“运行”时,它会像以前一样运行并忽略更改。如果我在第一次重试后按“运行”,它会应用更改。如果我第一次点击“Buld/Clean Project”,它也可以工作。

我究竟做错了什么?如何让 Android Studio 立即获取新代码?

干杯。

标签: androidandroid-studiokotlin

解决方案


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.


推荐阅读