If you encounter an error of type “Error 102 An object of the type Microsoft.SharePoint.Administration.SPSolution named “SolutionPackageName” already exists under the parent Microsoft.SharePoint.Administration.SPFarm named “SharePointContentDBName”. Rename your object or delete the existing object”, then even though if you remove the references of the solution in the sites, SharePoint will not allow to redeploy the solution.
The issue can be solved by, browse to the Central Administration -> Operations -> Solution Management and then delete the wsp file that caused the error and then redeploy the file again.
%stsadm% -o retractsolution -name sharepointrandomimagewebpart.wsp -url “http://app01:17768/sites/infoservice” -immediate
wait a minute then run
%STSADM% -o deletesolution -name sharepointrandomimagewebpart.wsp