-1
SignupUrl signupUrl = androidManagementClient
                .signupUrls()
                .create()
                .setProjectId(CLOUD_PROJECT_ID)
                .setCallbackUrl(CALLBACKURL).execute();

causes the app to crash due to NPE

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'com.google.api.services.androidmanagement.v1.AndroidManagement$SignupUrls com.google.api.services.androidmanagement.v1.AndroidManagement.signupUrls()' on a null object reference

Has anyone seen this before? I've followed all the prerequisites to developing and am currently going of off the sample app, and this is the piece of code that crashes. What could be the reason?

https://developers.google.com/android/management/sample-app

Update as per request:

Code

EnterpriseHelperClass - I'd like to do this programmatically even though I know this can easily be executed via the quickstart guide.

public class EnterpriseCreationHelper {
    private static final String CALLBACKURL =
            "https://play.google.com/work/adminsignup?enterpriseToken";
    private static final String TAG = "MainActivity";
    private static String CLOUD_PROJECT_ID = "******-";
    private static String SERVICE_ACCOUNT = "****@****-.iam.gserviceaccount.com";
    private static String CREDENTIALS_FILE =
            "/Users/****/appname/src/******.json";
    private static String POLICY_ID = "samplePolicy";
    private static AndroidManagement androidManagementClient;

    public EnterpriseCreationHelper(AndroidManagement androidManagementClient){
        EnterpriseCreationHelper.androidManagementClient = androidManagementClient;
    }

    public void run() throws IOException {

       
  • It doesn't seem that the `androidManagementClient` instance points to anything. Does it get assigned at some point? Can you add your code? – petarov Jan 21 '20 at 11:50

2 Answers2

1

Your androidManagementClient value is null. Kindly share the initialisation method of androidManagementClient it will be helpful for us to answer Thanks

Loganathan R P
  • 73
  • 1
  • 1
  • 7
0

Looks like getAndroidManagementClient is returning a null object, which results in setting androidManagementClient to null. Make sure your credentials are correct, and that this method returns successfully.

Deyzel
  • 186
  • 5