2

My application has 2 features: "base" and "extend".

manifest extend feature:

<dist:module
    dist:onDemand="true"
    dist:title="@string/title_extend">
    <dist:fusing dist:include="true" />
</dist:module>

download feature with SplitInstallManager -> startInstall

unintsalling with SplitInstallManager -> deferredUninstall

Check installed modules with SplitInstallManager -> getInstalledModules

Extend feature is loading from play store success and work as expected. When this feature has become unnecessary - uninstall it.

more, SplitInstallManager has callbacks: SuccessListener, FailureListener, CompleteListener. Install and Uninstall completely with success (no errors).

But, after uninstalling Extend feature (and after restart application) it is stay installed.

How to delete uninstalled feature from the application (need remove no used code and resources) ?

4 Answers4

4

As explained in the API of the deferredUninstall method:

Once called, the Play Store will try to eventually remove those modules in the background.

The uninstalled modules will be removed while the app is not working at some point in the next 24 hours.

Pierre
  • 15,865
  • 4
  • 36
  • 50
  • as official documents - yes. In really - no. The module was not deleted from the phone after 3 days( More, in callback SplitInstallManager no any data about delete, but about downloading - data exist. I think dynamic feature works only with downloading. Uninstalling and deleting are not works now. – Alexander Gromilov Apr 22 '19 at 07:22
  • Was the app installed through the Play store or sideloaded? – Pierre Apr 22 '19 at 07:40
  • File a bug so it can be investigated. – Pierre Apr 25 '19 at 07:24
1

Here is what I noticed.

1) Uninstalling the app removes the downloaded modules, so the next time you run the app, the app will download the modules again.

2) Clearing the app data (e.g. adb shell pm clear APP_PACKAGE_NAME) makes the module not available to the app immediately, but if the module is already downloaded before clearing the app data, it won't be downloaded again. In other words, you won't see SplitInstallSessionStatus.DOWNLOADING.

3) Once the downloadable module becomes available to the app, clearing the app data of "Google Play services" (i.e. adb shell pm clear com.google.android.gms) doesn't make a difference. But occasionally, the downloadable module sticks around even after uninstalling the app, especially when the module's name changes. Then 3) becomes handy to clear the stale modules.

I think what's happening here is when the app requests a downloadable module, Google Play services downloads the module, hands it over to the app, and caches a copy of it, just in case the app requests it again. If the app is uninstalled, Google Play services removes the cached module. deferredUninstall() is just asking Google Play services to uninstall the modules if necessary, but we have no control on when that would happen, if ever.

solamour
  • 2,764
  • 22
  • 22
0

from https://developer.android.com/guide/app-bundle/playcore#uninstall_modules:

Module uninstalls do not occur immediately. That is, the device uninstalls them in the background as needed to save storage space. You can confirm that the device has deleted a module by invoking SplitInstallManager.getInstalledModules() and inspecting the result, as described in the previous section.

So You could try to fill up storage space on your device and see if that triggers an uninstall :)

By the way: On the play store page for the app that I am currently testing via "internal early access", there is a section "deferred actions" which lists all modules marked for deferred uninstall. There also is a button "run deferred actions" which actually removes those modules completely.

0

As far as my own testing has gone, uninstall is deferred until the app is updated by Play Store. Otherwise I assume Play Store services will eventually wait for the app to be totally inactivate to update its uninstalled module (the app has to be restarted for that update to occur).

I've filled a bug to find out if there's anyway to force the (un)install of on-demand modules: https://issuetracker.google.com/u/1/issues/172108742. And a way to tell which modules are truly installed.

Same goes for installing actually, until app is updated, on-demand modules are "emulated", which prevents those 2 things from happening:

The platform can not apply any new manifest entries introduced by the module. The platform can not access the module’s resources for system UI components, such as notifications. If you need to use such resources immediately, consider including those resource in the base module of your app.

As explained here: https://developer.android.com/guide/playcore/play-feature-delivery#access_downloaded_modules

There seem to be a long road ahead before on-demand modules work properly.

3c71
  • 4,313
  • 31
  • 43