Loading

Deployment error 'Dependent class is invalid and needs recompilation'

Julkaisupäivä: May 1, 2026
Kuvaus

During a Salesforce deployment, test classes might fail with error: 'Dependent class is invalid and needs recompilation'

Apex classes and triggers are marked as valid as long as dependent metadata has not changed since the class was last compiled. If any changes are made to Object names or Fields used in the class — including superficial changes such as edits to an Object or Field description — or if changes are made to a class that calls this class, the isValid flag (a Salesforce internal flag that marks whether an Apex class is compiled and ready to run) is set to false.

This information is documented in the Defining Apex Classes article.

Note: All classes and triggers are marked as invalid when a managed package is upgraded in the organization.

Ratkaisu

 

This error occurs when Apex class dependencies have changed since the class was last compiled, causing the isValid flag to be set to false. The fix is to recompile all Apex classes and triggers in the target org before retrying the deployment.

Step 1: Compile All Apex Classes

  • Salesforce Classic: Setup > Develop > Apex Classes
  • Lightning Experience (LEX): Setup > Custom Code > Apex Classes
  • Click the 'Compile all classes' link.

Step 2: Compile All Apex Triggers

  • Salesforce Classic: Setup > Develop > Apex Triggers
  • Lightning Experience (LEX): Setup > Custom Code > Apex Triggers
  • Click the 'Compile all triggers' link.

Note on SOAP API Permissions

This error can also occur when the SOAP API is not purchased or enabled in your organization, or when a user does not have the API Enabled permission turned on in their assigned profile. See this information to determine the Salesforce supported editions where SOAP API is available by default and the required permissions.

What If the Error Persists?

If the above steps do not resolve the issue, visit the Stack Exchange, Trailblazer Community, or open a ticket with Salesforce Support  for further assistance.

Knowledge-artikkelin numero

000388111

 
Ladataan
Salesforce Help | Article