0

I am trying to create a second generation beta managed package for learning purpose.

Firstly I have created a namespace org where namespace is present. After that I have created a dev hub org in which I have enabled dev hub org permission and added my namespace org in this dev hub org.

Now I created a scratch Org using this dev hub org and done all of my development in this scratch org. In my development I have created a demo class, demo class's test class and a VF page (all for testing purpose) in this scratch org.

Now I have authorized my Scratch org and taken retrieve of all the components (Class, Test Class and VF page) in VS code.

Apex Class code: -

global class DemoAccountClass {

global static void createAccount(){
    Account acc = new Account();
    acc.Name = 'Test 1';
    insert acc;
    system.debug('@@ acc -- '+acc.id);
}

}

Test Class: -

@isTest
public class DemoAccountClass_Test {
@isTest
public static void method1(){
    Account acc = new Account();
    acc.Name = 'Test';
    Test.startTest();
    DemoAccountClass.createAccount();
    Test.stopTest();
}

}

VF Page: -

<apex:page standardController="Opportunity">
<apex:form >
    <apex:commandButton value="Google"/>
    <apex:commandButton value="Facebook"/>
</apex:form>
</apex:page>

Before creating Managed Package First I have connected my dev hub org and then executed these commands in VS code terminal where scratch org is authorized.

sfdx package:create --name Test_Project_123 --path force-app --package-type Managed -- 
target-dev-hub Test_dev

After running this command a beta package should be created but I am facing this error -

Error (1): The requested resource does not exist

Can anyone suggest any solution, why I am facing this error while creating 2nd generation managed package?

Thanks in advance.

4
  • 1. Is the dev hub alias valid? If you list orgs is that alias associated with your device hub? 2. Is your code under a folder called force-app and is this folder listed in your sfdx-project.json as a project directory?
    – Phil W
    Commented Jun 16, 2023 at 6:23
  • @PhilW Yes it is valid alias. Commented Jun 16, 2023 at 6:48
  • Please edit your question to show the content of sfdx-project.json (editing any IDs in it to "mask them") - please paste as text like you did for your code samples. It would be good to also illustrate your project's folder structure on disk. And, lastly, did you add the -meta.xml files for your metadata items into the folders alongside them?
    – Phil W
    Commented Jun 16, 2023 at 6:56
  • Hi @PhilW Thanks for response. I found the solution. There was a one permission "Enable Unlocked Packages and Second-Generation Managed Packages" which was not enabled by me. I just enabled it and everything is working fine now. Commented Jun 16, 2023 at 13:03

1 Answer 1

4

I just found the solution on my own. There was a permission in dev hub org Enable Unlocked Packages and Second-Generation Managed Packages which was not enabled.

I just enabled it and now everything is working fine.

1

You must log in to answer this question.

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