Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Annotations not working after update to v6.1.0 #362

Open
arpank10 opened this issue Feb 22, 2023 · 2 comments
Open

Custom Annotations not working after update to v6.1.0 #362

arpank10 opened this issue Feb 22, 2023 · 2 comments

Comments

@arpank10
Copy link

Updated Version : v6.1.0
Previous Version: v5.4.3

Annotation processor used: kapt

We have custom annotations to register deep links, they are defined like this:

@DeepLinkSpec(prefix = ["xyz://"])
annotation class AppDeepLink(vararg val value: String)

The functions are defined as follows:

@AppDeepLink(abc)
@WebDeepLink(abc)
 public static Intent registerDeepLink(Context context, Bundle bundle) {
        / * Deep Link handling */
        return intent;
}

The custom annotations were working fine with version 5.4.3, but they are not generated in the Registry with the new version.

Note: We have tried adding Retention(AnnotationRuntime.RUNTIME) to our custom annotation
The custom annotations are also added to our build.gradle and incremental processing is enabled.

@jramism
Copy link

jramism commented Jan 19, 2024

I am facing a similar problem, ksp saying all the time the error "Prefix property cannot be empty". I set the prefix and checked everything hundred of times and nothing

@jramism
Copy link

jramism commented Jan 20, 2024

Needed some time to reach what was happening but I found the reason of my problem. Seems that android BuildConfig variables are not supported in the DeepLink annotations because of a KSP limitation. I was using them as the root domain and then the processor was ignoring them like i wasn't set a value.

prefix = [ "https://" + BuildConfig.API_URL ] -> Doesn't work (handles it as empty string)
prefix = [ "https://example.com" ] -> Works

I worked on a workaround until google fixes ksp. Hope it helps if someone has the same problem. You need to put it in gradle.build, inside android section.

androidComponents {
        onVariants(selector().all(), { variant ->
            afterEvaluate {
                def variantName = variant.name.capitalize()
                def kspKotlinTaskName = "ksp${variantName}Kotlin"
                project.tasks.named(kspKotlinTaskName) { kspKotlinTask ->
                    def genBuildConfigTaskName = "generate${variantName}BuildConfig"
                    def genBuildConfigTask = project.tasks.named(genBuildConfigTaskName).get()
                    kspKotlinTask.setSource(
                        genBuildConfigTask.sourceOutputDir
                    )
                }
            }
        })
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants