Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I am trying to import OkHttp TLS to be able to use certificates and other OkHttp TLS functionality

my build.gradle.kts looks like this

implementation ("com.squareup.okhttp3:okhttp-tls")

However, gradle is unable to find this module

Could not find com.squareup.okhttp3:okhttp-tls

Unsure if okhttp tls is not imported this way any longer

The package does exist. It's odd that Gradle doesn't mention the version it cannot find. Are you using the okhttp bom to fix the versions? – Augusto Oct 28, 2022 at 8:32 @Augusto I am not using okhttp bom. I am going to try that and see if it fixes the find for me – TensorLearn Oct 28, 2022 at 15:36 @Augusto The bom seems to have fixed it. I don't have much knowledge about the bom, is it supposed to fix instances like this where the right packages can't be found? – TensorLearn Oct 28, 2022 at 15:43 The problem here is that there was a dependency specified, but without a version. The Bill of Materials (BOM) is a way to specify multiple dependency versions without depending on them. You don't need to use it, but it makes it easier to use some libraries that have multiple packages which might not be backwards compatible between themselves. Some very popular libraries that use this and come to my mind are are Jackson, okhttp and http4k. You can read a bit more about BOMs in the gradle docs – Augusto Oct 28, 2022 at 16:06
implementation("com.squareup.okhttp3:okhttp:4.10.0")

You can take a closer look at the docs

dependencies {
   // define a BOM and its version
   implementation(platform("com.squareup.okhttp3:okhttp-bom:4.10.0"))
   // define any required OkHttp artifacts without version
   implementation("com.squareup.okhttp3:okhttp")
   implementation("com.squareup.okhttp3:logging-interceptor")
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.