Friday 8 January 2021

How to Inject host and schema in AndroidManifest.xml for Android Deeplinking

I am trying to dynamically inject the url schema and path into my AndroidManifest.xml file using build.gradle as referenecd here

However, this does not allow deeplinks to trigger.

I tested my deeplinking works when I use static values in the AndroidManifest.xml.

            // AndroidManifest.xml
            <intent-filter>
            <action android:name="android.intent.action.VIEW" />

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

            <data
                android:scheme="${appScheme}"
                android:host="${hostName}"
                android:path="/path2" />

            <data
                android:scheme="${appScheme}"
                android:host="${hostName}"
                android:path="/path1" />
        </intent-filter>




// build.gradle (:app)
defaulConfig {
        manifestPlaceholders = [
        hostName: "www.host_name.com",
        appScheme: "https"
    ]
}


  demo {
        resValue "string", "hostName", "www.host_demo.com"
        resValue "string", "appScheme", "https"
    }

    staging {
        resValue "string", "hostName", "www.host_staging.com"
        resValue "string", "appScheme", "http"
    }


from How to Inject host and schema in AndroidManifest.xml for Android Deeplinking

No comments:

Post a Comment