raamcosta / compose-destinations

Annotation processing library for type-safe Jetpack Compose navigation with no boilerplate.
https://composedestinations.rafaelcosta.xyz
Apache License 2.0
3.23k stars 134 forks source link

Handle different scheme for debug and release build #658

Closed nizam-betterapp closed 4 months ago

nizam-betterapp commented 5 months ago

I want to keep different deeplink for debug and release builds. I have declared the below code but it's crashing with the below stacktrace. Please help.

Composable:

@Destination(
    deepLinks = [
        DeepLink(uriPattern = "$DEEPLINK_URL_HTTPS/$FULL_ROUTE_PLACEHOLDER"),
        DeepLink(uriPattern = "$DEEPLINK_URL_INTERNAL/$FULL_ROUTE_PLACEHOLDER"),
    ],
)
@Composable
fun BlockScheduleScreen() {
}

DeepLink Url:

const val DEEPLINK_URL_HTTPS = "https://link.example.ai"
const val DEEPLINK_URL_INTERNAL = BuildConfig.SCHEME_NAME + "://internal"

build.gradle

  debug {
            signingConfig signingConfigs.release
            applicationIdSuffix ".debug"
            buildConfigField "String", "SCHEME_NAME", "\"regainappdebug\""
            manifestPlaceholders = [scheme_name:"regainappdebug"]
            firebaseCrashlytics {
                mappingFileUploadEnabled false
            }
        }

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="$scheme_name" />
                <data android:host="internal" />
 </intent-filter>

Stacktrace:

FATAL EXCEPTION: main 
java.lang.IllegalStateException: The NavDeepLink must have an uri, action, and/or mimeType.
                                                                                                        at androidx.navigation.NavDeepLinkDslBuilder.build$navigation_common_release(NavDeepLinkDslBuilder.kt:60)
                                                                                                        at androidx.navigation.NavDeepLinkDslBuilderKt.navDeepLink(NavDeepLinkDslBuilder.kt:26)
                                                                                                        at
raamcosta commented 4 months ago

The solution here has to be adding the deep links at runtime rather than with the annotation.

Check here how to do that:

https://github.com/raamcosta/compose-destinations/releases/tag/2.1.0-beta07

I'm closing this, let me know if I can help any further 🙏