I have a working DPC app which is the Device Owner. I have tried this on two different Android 6.0.1 devices to rule out any device/manufacturer issues.
I used
The error was coming from the following Android 6.0.1 code in frameworks/base/services/core/java/com/android/server/pm/PackageManagerService.java
.
if ((pkg.applicationInfo.flags&ApplicationInfo.FLAG_TEST_ONLY) != 0) {
if ((installFlags & PackageManager.INSTALL_ALLOW_TEST) == 0) {
res.setError(INSTALL_FAILED_TEST_ONLY, "installPackageLI");
return;
}
}
I checked the app which I was trying to install, and found that the FLAG_TEST_ONLY
bit was set. Why is Android Studio 3.0.0 setting FLAG_TEST_ONLY on APKs?