I faced a similar problem after refactoring.
This is what i did to resolve this issue:
- Cleaned the Project
- Deleted the
Build
directory
- Restarted Android Studio
- Rebuild the Project
- Run
- Optionally (Go to the files menu on android, click on "Invalidate Caches / Restart..." uninstall the app on your phone and try again)
And everything worked fine!
I think the key is to restart your IDE.
Hope this helps you or anyone else!
Edit 1:
If the above steps don't work for you, then deleting Gradle cache seems to be a solution, as pointed out by @Yasitha.
Edit 2
As suggested by a couple of users in the comments below, sometimes the issue can be resolved by completely removing and reinstalling the app from your device.
Simply type adb uninstall <package>
in terminal to completely remove app from the device.
Edit 3
As mentioned in Abhishek's Answer, one should also try deleting the app from your device in case multiple users are set up on your device.
Simply go to Mobile Settings > Apps > [Your App] > More > Uninstall App for All Users
Edit 4
As mentioned by Yassin Ajdi, executing the uninstallAll
Gradle task can also fix the issue.
You can go to Gradle > Tasks > Install > uninstallAll
to get the job done.
UPDATE for Android Studio 2.1 and up
When running Android Studio 2.1 and up you can also encounter this issue when you have the instant run option enabled in your preferences (is enabled by default).
To disable this option go to the Preferences
option in the Android Studio
top menu and look for Instant Run
so you can uncheck the first checkbox on that screen.
Anyway that fixed it for me. Originally pointed out by user @yusufonder. I discovered this was the issue since gradle install still worked.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…