Sorry if this is not something to be done on your ...
# apollo-kotlin
s
Sorry if this is not something to be done on your end, but I tried using https://github.com/autonomousapps/dependency-analysis-gradle-plugin/tree/main?tab=readme-ov-file on my project, and I am getting some errors about a task named explodeCodeSourceDebug having an input on apollo's generateXApolloSources and I am not sure if this is something on me, on apollo, or on the DAGP. The error in thread 🧡
Copy code
Some problems were found with the configuration of task ':apollo-octopus-public:explodeCodeSourceDebug' (type 'CodeSourceExploderTask').
  - Gradle detected a problem with the following location: '/Users/stylianosgakis/WorkProjects/hedvigandroid/app/apollo/apollo-octopus-public/build/generated/source/apollo/octopus/octopus/FlowClaimLocationNextMutation.kt'.
    
    Reason: Task ':apollo-octopus-public:explodeCodeSourceDebug' uses this output of task ':apollo-octopus-public:generateOctopusApolloSources' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
    
    Possible solutions:
      1. Declare task ':apollo-octopus-public:generateOctopusApolloSources' as an input of ':apollo-octopus-public:explodeCodeSourceDebug'.
      2. Declare an explicit dependency on ':apollo-octopus-public:generateOctopusApolloSources' from ':apollo-octopus-public:explodeCodeSourceDebug' using Task#dependsOn.
      3. Declare an explicit dependency on ':apollo-octopus-public:generateOctopusApolloSources' from ':apollo-octopus-public:explodeCodeSourceDebug' using Task#mustRunAfter.
    
    For more information, please refer to <https://docs.gradle.org/8.10.2/userguide/validation_problems.html#implicit_dependency> in the Gradle documentation.
b
πŸ‘€ Looks similar to this issue
m
What is even this
explodeCodeSourceDebug
task? Something AGP?
Ah no, something from DAGP
@Stylianos Gakis do you have a reproducer for this?
s
Hmm yes, it's our latest develop right now, it seems to happen all the time, but it's not buildable by you right now since you will be missing some authenticated dependencies + strings and whatever. If you however want, I can take a few minutes to try and make a branch which should be buildable after just cloning. It shouldn't take me long to do. But it will be on our entire big project, if that would not really be workable for you then perhaps a small sample project would be a better idea
m
Let me see if the tutorial repros
Can't reproduce there sadly. If you have a branch handy, that'd be useful!
s
Alright, I will jump on this soon, I'll be back here later with a repro hopefully 😊
πŸ™ 1
So, go to https://github.com/HedvigInsurance/android and clone Switch to the
dagp-repro
branch where I've deleted the stuff you don't have (also makes the app not functionally work as you get stuck on the splash screen waiting for the auth to resolve, but that's not important) *Here I also had to go to
Settings | Build, Execution, Deployment | Build Tools | Gradle
and change Gradle JDK to my "JAVA_HOME" otherwise gradle doctror was complaining Sync project Finally run
./gradlew buildHealth
And see the error show up, along with a lot of other things around android resource linking failures, which are also just showing up when I started running this build health project, I think you can safely ignore
❀️ 1
m
Thanks!
πŸ™‡ 1
Got a bunch of
Copy code
> Android resource linking failed
     ERROR: /Users/martinbonnin/git/hedvig-android/app/core/core-resources/build/intermediates/packaged_res/debug/packageDebugResources/drawable/ic_back.xml:2: AAPT: error: resource attr/colorPrimary (aka com.hedvig.android.data.chat.test:attr/colorPrimary) not found.
Trying to workaround
s
Do you also get the error I mentioned at the top of the long error message?
I don't get these errors under normal tasks btw, only this build health task does it
m
All good, looks like doing
./gradlew :buildHealth
works βœ…
Do you remember why you used
connectToKotlinSourceSet("main")
?
s
I don't remember that line, but I do remember the comment I have right above it. I would have issues with an IDE warning saying among other things something like "duplicate sources found" and it would just bug me a lot. And explicitly adding this "main" got rid of that warning. That's what I remember, but I don't know for sure πŸ˜… So with the change you did now, what is different? I don't think I've seen this
connectToAllAndroidVariants()
before πŸ‘€
m
`connectToAllAndroidVariants()`is the default, if you leave the whole
outputDirConnection {}
out
β€’
connectToAllAndroidVariants()
goes through all android variants and calls
registerJavaGeneratingTask()
(yea, I know πŸ˜… )
β€’
connectToKotlinSourceSet("main")
goes through
kotlin.sourceSet("main")
directly, which is then included by all variants
So
connectToKotlinSourceSet("main")
doesn't need to know about AGP and is much simpler but also in some cases like this it behaves a bit differently
s
Hmm right, so the trade-off with this change is that things might be doing a bit extra work, therefore be a bit more expensive perhaps? Because if I end up not using DAGP if it ends up being too much effort, I suppose I should keep this as I had it before right?
m
I have absolutely no idea TBH
This has been a dark place of AGP/KGP/Gradle/Apollo for a while
s
Understandable, thanks a ton for looking into this btw!
m
Filed this issue to try to un-entangle all of this: https://issuetracker.google.com/u/2/issues/376709932
🌟 1
I'd love to get this clarified. Every plugin has their own recipe for this at the moment and all have slightly different edge cases
s
Just thought I'd link this here https://github.com/autonomousapps/dependency-analysis-gradle-plugin/issues/1185#issuecomment-2453749727 in case you were interested to hear the answer from the DAGP maintainer as well regarding other people facing the same issue when using DAGP. Good to note here I think that this problem did not come from apollo-kotlin, but some other plugin which also did something similar. That is my understanding of it at least.
πŸ™ 1
m
Just left a comment for posterity. Thanks again for diving into this!
thank you color 1