Programmatically install/uninstall apk from local asset directory to real device in android studio

181 Views Asked by At

For Automation Testing I need to install on Apk programmatically and verify that the app is installed. and programmatically uninstall it and verify the app is uninstalled from the real device. I am not looking for a UI to download and install, without any UI when I run the java file in the android studio it should install/uninstall. Can anyone tell me how can I achieve this?

1

There are 1 best solutions below

0
zen_of_kermit On BEST ANSWER

You can likely achieve this by using a combination of PackageInstaller and PackageManager

As mentioned in the documentation for PackageInstaller, you'll need to be either the device owner or the affiliated profile owner, or it will require user intervention to complete installation.