sixo / silent-update

Sample that shows how to update Android app silently without user confirmation
Apache License 2.0
30 stars 7 forks source link

Same piece of code execued in Oreo Am unable to install updated Apk. #2

Open Narendrakumar-Vanamala opened 4 years ago

Narendrakumar-Vanamala commented 4 years ago

I tried out this project am unable to updated apk with new version code.

Please illustrate more details how to execute and what is procedure to install updated apk without user interaction.

If possible please provide me the detailed steps to achieve this.

after session.commit() - Nothing happened.

sixo commented 4 years ago

The procedure is described in detail here (mentioned in README.md) https://sisik.eu/blog/android/dev-admin/update-app

It was tested on devices up until Android 10 and working as expected. Make sure that

Narendrakumar-Vanamala commented 4 years ago

Thanks for the quick update

Need some clarification on few points.

1.adb shell dpm set-device-owner eu.sisik.devowner/.DevAdminReceiver - This cmd used to set device owner as a first point what you mentioned in the above. 2.Next step am setting testOnly true in the manifest file and run the application on device with version code 4 clarification required here, shall i generated singed build or debug build. 3.Now setting testOnly flag as false and generate new build with version code 5 and make it available from one of the folder - I provided permission for read & write. Now am able to the access the file. clarification required here, shall i generated singed build or debug build.

  1. All required permissions provided.

and one more observation found like val dpm = getSystemService(Context.DEVICE_POLICY_SERVICE) as DevicePolicyManager if (dpm.isDeviceOwnerApp(packageName)) Log.d(TAG, "is device owner") else Log.d(TAG, "not device owner") Even am executing above first step, this method returns false always am getting logs as not device owner.

Please advice me on this.

sixo commented 4 years ago

Starting since Android 7 (I think), you need to set testOnly flag to true (or use debug build), before you can call adb shell dpm .... Otherwise you'll get an error. So device owner won't be activated without this flag.

Once your app is activated as device owner, all updates (new apks with higher version code) should be build with testOnly=false

But from your last comment it looks like your issue is that you were not able to set your app as device owner. The shell command (adb shell dpm...) usually returns some hint on what's wrong. The usual issue is that you were not following the instructions carefully or you didn't read the error message properly (e.g. the device should have no accounts added before dev owner activation). In rare cases the OEM did something that won't allow you to activate your app as device owner.

Narendrakumar-Vanamala commented 4 years ago

Thanks a lot for your support.

When am executing this command prompt adb shell dpm... it's goes to next line and blinking nothing happen not showing any errors as well.

sixo commented 4 years ago

So it looks like the issue is with your device. The command has to print out "SUCCESS" after executing. I guess there are some modifications to the standard Android system behaviour on your device. Sorry, can't help you with this.

Narendrakumar-Vanamala commented 4 years ago

Thanks for your support.

I will try to test another device and if any support required updated here.

Thank you once again

sixo commented 4 years ago

Maybe you could write the exact device model that wasn't working. Might help other people that want to create a kiosk device to decide what not to buy.