0

When installing or run from the Android Studio my app, I see two entry points of my app: The installable app's launcher activity and the instant app launcher activity.

  1. How can I exclude my Instant App launcher activity from the installed app?
  2. Do I need different version codes for installed and instant app? And how to achieve this since I need applicationId which isn't allowed for dynamic-feature?
  3. Or maybe I need both activities to be the same name?
  4. Do I need to use same namespace/package name in the installable and instant modules?

In my case I have 3 modules:

app - the base module holding base code for both instant and installable app.

installableFeature - the code needed in the installed app. It has it's own launcher activity!

instant - the code needed only for the instant app. It has it's own launcher activity!

Following this documentation Convert an existing game to an instant game as far as I understand I need android.intent.category.LAUNCHER in otder to achieve Try Now button in my app. But as far as I understand, the installed app includes the instant module as well and this causes the both instant and installable entry points to be shown in the launcher.

(app) build.gradle

plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
}

android {
    namespace 'com.example'
    compileSdk 34

    dynamicFeatures = [':installableFeature', ':instant']

    defaultConfig {
        applicationId "com.example"
        minSdk 26
        targetSdk 34
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
/////
}

dependencies {
    implementation "com.google.android.gms:play-services-instantapps:18.0.1"

    implementation 'androidx.core:core-ktx:1.12.0'
////
}

(installableFeature) build.gradle

plugins {
    id 'com.android.dynamic-feature'
    id 'org.jetbrains.kotlin.android'
    id 'androidx.navigation.safeargs.kotlin'
}

android {
    namespace 'com.example.installable'
    compileSdk 34

    defaultConfig {
        minSdk 26

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    ///

}

dependencies {
    implementation project(":app")

    implementation 'androidx.core:core-ktx:1.12.0'
    implementation 'androidx.appcompat:appcompat:1.6.1'
    ///

}

(instant) build.gradle

plugins {
    id 'com.android.dynamic-feature'
    id 'org.jetbrains.kotlin.android'
    id 'androidx.navigation.safeargs.kotlin'
}
android {
    namespace 'com.example.instant'
    compileSdk 34

    defaultConfig {
        minSdk 26

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    ///

}

dependencies {
    implementation project(":app")

    implementation "com.google.android.gms:play-services-instantapps:18.0.1"
    ///

}

(app) AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:dist="http://schemas.android.com/apk/distribution">

    <dist:module dist:instant="true" />

    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/Theme.MyTheme" />

</manifest>

(installableFeature) AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:dist="http://schemas.android.com/apk/distribution"
    xmlns:tools="http://schemas.android.com/tools"
    android:targetSandboxVersion="2">

    <dist:module
        dist:instant="false"
        dist:onDemand="false"
        dist:title="@string/title_dynamic_feature">
        <dist:fusing dist:include="true" />
    </dist:module>

    <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:name="com.example.installable.MyApp"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/Theme.MyTheme"
        tools:targetApi="33">
        <activity
            android:name="com.example.installable.ui.main.MainActivity"
            android:launchMode="singleInstance"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

(instant) AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:dist="http://schemas.android.com/apk/distribution"
    xmlns:tools="http://schemas.android.com/tools">

    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <dist:module
        dist:instant="true"
        dist:title="@string/title_instant">
        <dist:delivery>
            <dist:install-time />
        </dist:delivery>
        <dist:fusing dist:include="false" />
    </dist:module>

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/Theme.MyTheme"
        tools:targetApi="33">
        <activity
            android:name="com.example.instant.main.MainInstantActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

            <meta-data
                android:name="default-url"
                android:value="https://example.github.io" />

            <intent-filter android:autoVerify="true">
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <data android:scheme="http" />
                <data android:scheme="https" />
                <data android:host="example.github.io" />
            </intent-filter>

        </activity>
    </application>
</manifest>

I updated the From Factors and uploaded 2 different releases: one for the installed app and one for the Instant Only. I create the app bundles the same way and actually upload the same file, app-release.aab, in both places. I have the assetlinks.json working and verified, because otherwise the th Play Console isn't allowing me to upload the instant release.

0

Browse other questions tagged or ask your own question.