Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

App Bundle, In Dynamic Feature Module, Module available before install

I try to implement dynamic feature module in my app. I have button in Activity. When user click I check module already installed or not. if not i start Install using startInstall(request). But I always goes to else state.

Code

    if (manager.installedModules.contains("sample")) {
-----> Always go to this block 
                Toast.makeText(this, "Already Downloaded", Toast.LENGTH_SHORT).show()
                Intent().setClassName(packageName, "com.example.sample.SampleActivity")
                        .also {
                            startActivity(it)
                        }
            } else {
               // Never came to this state
                // Create request to install a feature module by name.
                val request = SplitInstallRequest.newBuilder()
                        .addModule("sample")
                        .build()
                // Load and install the requested feature module.
                manager.startInstall(request)
            }

In Dynamic feature module I set onDemand="true"

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:dist="http://schemas.android.com/apk/distribution"
package="com.example.sample">

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

<application>
    <activity android:name="com.example.sample.SampleActivity">
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
        </intent-filter>
    </activity>
</application>

like image 967
Magesh Pandian Avatar asked Nov 13 '18 10:11

Magesh Pandian


People also ask

How is dynamic feature module implemented?

To add a dynamic feature module to your app project using Android Studio(3.2 Canary 14+), proceed as follows: Note : Before creating a dynamic module, you have to create you app bundle. Select File > New > New Module from the menu bar. In the Create New Module dialog, select Dynamic Feature Module and click Next.

Can we install app bundle in Android?

App bundles are only for publishing and cannot be installed on Android devices. The Android package (APK) is Android's installable, executable format for apps. App bundles must be processed by a distributor into APKs so that they can be installed on devices.

What is dynamic feature module?

Dynamic feature modules allow you to separate certain features and resources from the base module of your app and include them in your app bundle. Through Dynamic Delivery, users can later download and install those components on demand after they've already installed the base APK of your app.

What is a bundle in an Android application?

An Android App Bundle is a publishing format that includes all your app's compiled code and resources, and defers APK generation and signing to Google Play.


1 Answers

Currently the only way to test your implementation of onDemand delivery is by uploading the .aab to the PlayStore.

The standard deployment from Android Studio deploys all modules to the attached device.

In a development environment the flow is correct, that the module is already installed when it's deployed to device.

As for code, take a look at the sample app, in particular the download and listener implementation of MainActivity.

like image 161
keyboardsurfer Avatar answered Sep 20 '22 16:09

keyboardsurfer