1 year ago

#187686

test-img

pauminku

DeepLinkDispatch with different modules (libraries)

I'm trying to add DeepLinkDispatch library (by airbnb) in my project in order to handle deeplinks. The project has different modules and some links needs to be handled by Activity's in this modules.

As I have different flavors I would like to define the url of deeplinks with BuildConfig in build.gradle, to be able to do something like this:

@DeepLink("${BuildConfig. WEB_BASE_URL}/deepLink/{id}", "${BuildConfig. WEB_BASE_URL}/anotherDeepLink")
class ModuleActivity : AppCompatActivity() {
   // This class is in :module, so it has no access to BuildConfig main :app module
}

But unfortunately I don't have access to BuildConfig from modules

I also tried to reproduce the flavors in Modules like this:

//module build.gradle
plugins {
    id 'com.android.library'
    id 'kotlin-android'
    id 'kotlin-android-extensions'
    id 'kotlin-kapt'
}
apply plugin: 'dagger.hilt.android.plugin'

apply from: rootProject.file("buildscripts/android-defaults.gradle")

import dependencies.deps

android {
    defaultPublishConfig "alphaRelease"
    publishNonDefault true

    defaultConfig {

    }
    flavorDimensions "env"
    productFlavors {
        alpha {
            buildConfigField "String", "WEB_BASE_URL", "\"https://staging.example.com\""
            dimension "env"
        }
        production {
            buildConfigField "String", "WEB_BASE_URL", "\"https://example.com\""
            dimension "env"
        }
    }
}
dependencies {
    //...
}

but it seems this is not possible, I'm getting this error:

Product Flavor 'alpha' contains custom BuildConfig fields, but the feature is disabled.

Is there any way to solve this without hardcoding the whole url in the @DeepLink annotation?

EDIT: this is the main app build.gradle

apply plugin: 'com.android.application'
//**

android {
    defaultConfig {
        //**
    }
    
    productFlavors {
        alpha {
            applicationIdSuffix '.alpha'
        }
        production {
            applicationIdSuffix '.prod'
        }
    }
    //**
}

dependencies {
    implementation project(':module')
    //**
}

android

android-deep-link

android-module

android-flavors

buildconfig

0 Answers

Your Answer

Accepted video resources