Slackbot
11/08/2023, 1:24 PMVampire
11/08/2023, 2:12 PMVampire
11/08/2023, 2:14 PMidea.sync.active is present.Chenai Nakam
11/08/2023, 2:28 PMidea.sync.active ? I'm using Android studio.Chenai Nakam
11/08/2023, 2:50 PMR.id.xxx in kotlin/java code to files under /res, but not sure. Maybe it retrofits Android Studio.Chenai Nakam
11/08/2023, 3:11 PMExternal Libraries by adding the following code, how can I accomplish it?
project.dependencies.add(appRJarConfName, project.files(
processRes.outputs.files.find {
it.path.endsWith("${variant.name}/R.jar")
})
)
Like this:Chenai Nakam
11/08/2023, 3:16 PMdependencies {
compileOnly fileTree(include: '**/R.jar', dir: 'build/intermediates/compile_and_runtime_not_namespaced_r_class_jar')
// ...
}Chenai Nakam
11/08/2023, 3:26 PM./gradlew :app:assembleGithubDebug
But error when exec ./gradlew :app:assemble for all variants. And the error it reports is not the real reason:
> Task :app:compileScalaGoogleplayDebugCrossScope FAILED
FAILURE: Build failed with an exception.
* What went wrong:
A problem was found with the configuration of task ':app:compileScalaGoogleplayDebugCrossScope' (type 'ScalaCompile').
- Gradle detected a problem with the following location: '/Users/weichou/git/bdo.cash/demo-material-3/app/build/intermediates/compile_and_runtime_not_namespaced_r_class_jar/githubDebug/R.jar'.
Reason: Task ':app:compileScalaGoogleplayDebugCrossScope' uses this output of task ':app:processGithubDebugResources' 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 ':app:processGithubDebugResources' as an input of ':app:compileScalaGoogleplayDebugCrossScope'.
2. Declare an explicit dependency on ':app:processGithubDebugResources' from ':app:compileScalaGoogleplayDebugCrossScope' using Task#dependsOn.
3. Declare an explicit dependency on ':app:processGithubDebugResources' from ':app:compileScalaGoogleplayDebugCrossScope' using Task#mustRunAfter.
For more information, please refer to <https://docs.gradle.org/8.2.1/userguide/validation_problems.html#implicit_dependency> in the Gradle documentation.Vampire
11/08/2023, 3:27 PMVampire
11/08/2023, 3:29 PMChenai Nakam
11/08/2023, 3:33 PMVampire
11/08/2023, 3:36 PM:app:processGithubDebugResources creates this file and thus has it properly declared as output.
By adding this file to compileOnly you make :app:compileScalaGoogleplayDebugCrossScope use the file as input.
But those two tasks do not have a dependency as the error says.Vampire
11/08/2023, 3:37 PMThat's why I want to make the tasks connected correctly by coding in the plugin.As I said, I have near to no knowledge about Android. The problem probably is, that you declare the R.jar of one variant as dependency for all variants and thus those tasks are no connected. If you would only do it during IDE sync, this problem should not exist I'd say.
Chenai Nakam
11/08/2023, 3:42 PMproject.dependencies.add(appRJarConfName, project.files(
processRes.outputs.files.find {
it.path.endsWith("${variant.name}/R.jar")
})
)
appRJarConfName separates the variants. But only this code is not working.
I mean I want the dependency to appear under External Libraries .Chenai Nakam
11/08/2023, 3:50 PMVampire
11/08/2023, 4:02 PMChenai Nakam
11/08/2023, 4:07 PMChenai Nakam
11/08/2023, 4:50 PMcompileOnly (if there are other mechanisms bundled with IDE).Vampire
11/08/2023, 4:52 PMcompileClasspath configuration extends from it, but runtimeClasspath does not.
By that it is part of the compile classpath but not of the runtime classpath.Chenai Nakam
11/08/2023, 4:55 PMorg.gradle.api.artifacts.Configuration, i need to know more.Chenai Nakam
11/08/2023, 5:02 PMVampire
11/08/2023, 5:13 PMVampire
11/08/2023, 5:20 PMChenai Nakam
11/11/2023, 2:20 PMproject.dependencies.add("${variant.name}CompileOnly", project.files(
processRes.outputs.files.find {
it.path.endsWith("${variant.name}/R.jar")
})
)
So i guess there must be some mechanism behind compileOnly (just change appRJarConfName to "${variant.name}CompileOnly" and it works fine).