Search code examples
android-studiodependenciesbuild.gradle

Gradle implementation 'org.jsoup:jsoup:1.11.1' Too many characters error


I want to do web scraping in android application. But I faced with a problem at the beginning.

I'm trying to add 'org.jsoup:jsoup:1.18.1'dependency to my project and get the following error: *Too many characters in a character literal ''org.jsoup:jsoup:1.18.1''*

Error picture

I am using Android Studio Koala 2024.1.2, Gradle 8.7


Solution

  • Have are using a Kotlin based gradle configuration and in Kotlin (just like in Java) single quotes ' are used for declaring single characters like 'a'. Multiple characters in single quote are not allowed, therefore you are getting the error Too many characters in a character literal.

    You want to declare a string not a character, thus you have to use double quotes:

    implementation("org.jsoup:jsoup:1.18.1")
    

    See also the Gradle documentation: https://docs.gradle.org/current/userguide/declaring_dependencies.html#sec:dependency-types

    Please don't mix up Kotlin with JavaScript or Python where strings can be declared using single or double quotes.