Revert "Fixing the add new app fail issue"

This reverts commit efeb1fa555734af3df39b967b788b93ac1b87601.
Revert "Revert "Fixing the add new app fail issue""

This reverts commit d571aa884e123d15c38ea2170c795ba11f9d7d25.
Applying ChathuraD's patch
Applying ChathuraD's patch