I want to deploy using metadata API. I have class classes/MyPackage__UninstallClass.cls with MyPackage namespace classes/MyPackage2__UninstallClass.cls with MyPackage2 namespace. But when I try to deploy Salesforce give me an error message:

File name mismatch with class name: UninstallClass I can not rename class as MyPackage__UninstallClass Maybe it is necessary to add something in addition into package.xml or in MyPackage__UninstallClass.cls-meta.xml. What I should do?

  • What are you trying to do specifically? You can't update a class in a managed package (that's what "managed" means).
    – sfdcfox
    Commented Jan 24, 2019 at 16:49

2 Answers 2


First be sure that you are trying to update an unmanaged or unlocked package. You cannot update managed packages.

Second, your package,xml file needs to have the package name in the fullname parameter, but the Apex class name does not have a namespace. For example:

    <?xml version='1.0' encoding='UTF-8'?>
    <Package xmlns="http://soap.sforce.com/2006/04/metadata">

Lastly, be sure that the class name in your actual code matches the file name:

    public class UninstallClass {

I do know if anyone is still having trouble with this but if you...

  1. Rename your file name
  2. Delete the meta.xml file and recreate it with the new name
  3. Redeploy it

This worked for me. Also, you will need to make sure you delete your old file from the org

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .