Error on device-policy(clouddpc): policies.json file not found for dedicated devices using Android Management API

236 views Asked by At

I am using Android-Management API and QR Code scan after factory reset to provision devices as dedicated device. but provisioning process fail because device-policy app is installed but failed to sync policies. I checked with "adb logcat" while trying to manually sync policies using device-policy app. adb logcat shows:

12-03 00:01:53.833  8043 10532 E clouddpc: [PolicyDetailsPreferenceFragment] Error populating policy list for display.
12-03 00:01:53.833  8043 10532 E clouddpc: java.io.FileNotFoundException: /data/user/0/com.google.android.apps.work.clouddpc/files/policies.json (No such file or directory)
12-03 00:01:53.833  8043 10532 E clouddpc:      at java.io.FileInputStream.open0(Native Method)
12-03 00:01:53.833  8043 10532 E clouddpc:      at java.io.FileInputStream.open(FileInputStream.java:231)
12-03 00:01:53.833  8043 10532 E clouddpc:      at java.io.FileInputStream.<init>(FileInputStream.java:165)
12-03 00:01:53.833  8043 10532 E clouddpc:      at android.app.ContextImpl.openFileInput(ContextImpl.java:560)
12-03 00:01:53.833  8043 10532 E clouddpc:      at android.content.ContextWrapper.openFileInput(ContextWrapper.java:202)
12-03 00:01:53.833  8043 10532 E clouddpc:      at deo.c(PG:1)
12-03 00:01:53.833  8043 10532 E clouddpc:      at com.google.android.apps.work.clouddpc.ui.statusui.PolicyDetailsPreferenceFragment.az(PG:13)
12-03 00:01:53.833  8043 10532 E clouddpc:      at dvp.call(Unknown Source:2)
12-03 00:01:53.833  8043 10532 E clouddpc:      at ign.c(PG:1)
12-03 00:01:53.833  8043 10532 E clouddpc:      at ift.run(PG:4)
12-03 00:01:53.833  8043 10532 E clouddpc:      at igo.run(PG:1)
12-03 00:01:53.833  8043 10532 E clouddpc:      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
12-03 00:01:53.833  8043 10532 E clouddpc:      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
12-03 00:01:53.833  8043 10532 E clouddpc:      at java.lang.Thread.run(Thread.java:764)
12-03 00:02:01.791  8043  8043 I clouddpc: [PolicyDetailsPreferenceFragment] Current state: hasTokenKey=false hasSetupStarted=false wasDeviceEverCompliant=false hasSetupFinished=false

Can anyone please help me to fix this issue?

1

There are 1 answers

0
Kevin On

This usually happens when you create an enrollment token without a policy. If you want to enroll a device without a policy, it is advisable to create a blank policy and assign it during the creation of the enrollment token instead.

policy_name = enterprise_name + '/policies/policy_default'
policy_json = {}

policy = androidmanagement.enterprises().policies().patch(
    name=policy_name,
    body=policy_json
).execute()

enrollment_token = androidmanagement.enterprises().enrollmentTokens().create(
    parent=enterprise_name,
    body={"policyName" : policy_name}
).execute()

If the device enrolled is not linked with a policy within 5 minutes, the enrollment will fail and the device will be factory reset.