Home » Android » Android Studio 3.0 Kotlin changes are not reflected in the build

Android Studio 3.0 Kotlin changes are not reflected in the build

Posted by: admin May 14, 2020 Leave a comment

Questions:

Has anyone tried the new android studio with 3.0 for kotlin. I am seeing a weird issue where the Kotlin code changes are not reflected when I run the app but the java changes can be seen. When I debug the app, the code won’t stop at the new lines of code. Also I’ve particularly seen that during runtime Java complains that the new method that I wrote in Kotlin cannot be found.(But the java code which was written at the same time can be seen) The only solution I’ve found is either to rebuild the app or uninstall and reinstall. Any solutions for this problem.
NB: I’ve instant run OFF and also tried incremental compilation on kotlin build OFF/ON

How to&Answers:

I was going though the same problem. I thought that the changes are not getting saved so I even tried to clean build my application but sadly that didn’t work.
So lately I found what’s wrong is that I was using an if expression and as an expression returns a value, my call after the if expression was not getting executed not because the changes are not saved but because if was returning to the function hence no statement after the call was executed.
Please check if that was the case. Hope this might help.

Answer:

Try running ./gradlew clean assemble in the terminal. That should clean all the autogenerated code and build all the flavors of your app from scratch.

If that doesn’t work, try then invalidating all the caches and restarting Android Studio, that should also do.