You need to sign in to do that
Don't have an account?

Error: Compile Error: Package Visibility: Type is not visible
I just ran in to a problem where I was trying to reference Apex code that lived in a Managed Package, and even though I had the correct syntax, I just couldn't get my code to compile properly. I'd like to share the solution with you.
Here's a simplified version of the code that was frustrating me:
public class PackageExtenderClass{
public PackageExtenderClass(){
}
public String myExtenderMethod(){
String temp = myNamespace.UtilityClass.getRandomString();
return temp;
}
}
The above code is correct in every way, but I couldn't get it to compile - I kept getting this error:
Error: Compile Error: Package Visibility: Type is not visible: utilityclass at line 7 column 26
It turns out that in order to solve this problem, I needed to update the Version Settings for my PackageExtenderClass so that it referenced the 1.6 version of the 'myNamespace' Managed Package instead of the older 1.3 version. This is becuase the 1.3 version of the Managed Package didn't include a definition for the getRandomString() method. The getRandomString() method was only added in the 1.6 version of the Managed Package.
Daniel,
From Setup | Develop | Apex Classes | <Your Class> | [Edit], you can edit the dependency information on the Version Settings tab. Alternatively, you can edit the dependency in <Your Class>.cls-meta.xml, within the packageVersions tag.
Christian
All Answers
Thanks. This had me scratching my head.
You get a confusing error message with VisualForce pages as well:
Exception: Dependent class is invalid and needs recompilation
Updating the version number in the .page-meta.xml file fixed the problem.
Hi,
Can you please clarify how you updated the version settings for the apex class to reference a specific version of the managed package?
Thanks,
Daniel
Daniel,
From Setup | Develop | Apex Classes | <Your Class> | [Edit], you can edit the dependency information on the Version Settings tab. Alternatively, you can edit the dependency in <Your Class>.cls-meta.xml, within the packageVersions tag.
Christian
Thanks, I'd just found my way there through the help documents:
Also, the class that you are going to call in the managed package needs to be marked as global
i have installed package in my org.now i wanted to access the class of managed package in my class.how can i call?thanks
Compile Error for contactpage.page: Apex class 'Contactpage1' does not exist at line None column None
What is the reason Iam Mentioning on apexclass same like as visualforcec page but it is not working can u please tell me
Visualforce page:
<apex:page controller="Contactpage1">
<apex:form>
<apex:pageBlock title="Contact Edit">
<apex:pageBlockButtons location="both">
<apex:commandButton action="{!Savecnct}" value="Save Contact"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="Contact Information" collapsible="false">
<apex:pageBlockSectionItem>
<apex:outputLabel>
First Name
</apex:outputLabel>
<apex:inputField value="{!Contact.FirstName}">
</apex:inputField>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem>
<apex:outputLabel>
Last Name
</apex:outputLabel>
<apex:inputField value="{!Contact.LastName}">
</apex:inputField>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem>
<apex:outputLabel>
Email
</apex:outputLabel>
<apex:inputField value="{!Contact.Email}">
</apex:inputField>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem>
<apex:outputLabel>
Department
</apex:outputLabel>
<apex:inputField value="{!Contact.Department}">
</apex:inputField>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem>
<apex:outputLabel>
Birthdate
</apex:outputLabel>
<apex:inputField value="{!Contact.Birthdate}">
</apex:inputField>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:pageBlockSection title="Address Information" collapsible="false">
<apex:pageBlockSectionItem>
<apex:outputLabel>
Mailing Street
</apex:outputLabel>
<apex:inputField value="{!Contact.MailingStreet}">
</apex:inputField>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem>
<apex:outputLabel>
Other Street
</apex:outputLabel>
<apex:inputField value="{!Contact.OtherStreet}">
</apex:inputField>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Apex class:
public with sharing class Contactpage1 {
public String cnctFirstName{set;get;}
public Contactpage(){
}
public PageReference Savecnct();{
Contact cnct = new Contact();
cnct.FirstName = cnctFirstName;
insert cnct;
System.debug('cnct'+cnct);
try{
PageReference pgRef = new PageReference('/'+cnct.Id);
return pgRef;
}catch(Expection e){
System.debug(e.getMessage());
}
return null;
}
}
Thanks ,
Ravi teja