錯誤彈窗如圖:

Installation failed with message Failed to finalize session: INSTALL_FAILED_TEST_ONLY:installPackageLI.
It is possible that this issue is resolved by uninstalling an existing version of the apk if it is present, and then re-installing.
WARNING: Uninstalling will remove the application data!
Do you want to uninstall the existing application?
解決方法:
1、打開菜單File——Settings——Build,Execution,Deployment——Instant Run
2、不選中Enable Instant Run to hot swap code/resource changes on deploy(default enabled)
3、依次點擊Apply——OK,重新運行程序,大功告成。

備注:筆者所用手機是華為榮耀7,百度發現有人用小米手機也遇到這樣的問題,解決方式是通用的,如果其他手機也遇到這種問題,歡迎大家留言討論。
如果你沒有成功,接下來使用第二招。
1、打開Edit Configurations...
2、在Install Flags中寫上“-t”
3、依次點擊Apply——OK,重新運行,大功告成。

到此問題已經解決。
如果你還沒有解決,我也沒有第三招了,如果你有了第三招,請記得留言告訴我一下~~~
