This looks more like you've named your own class the same way as the Gson JsonParser
class. So the compiler resolves JsonParser
to your own class (your.package.JsonParser
) and not to the Gson JsonParser (com.google.gson.JsonParser)
. You may want to rename your class or use com.google.gson.JsonParser
instead of JsonParser
each time you want to refer to this class.
Another possibility is that the Gson
library that you're using might be older than version 2.8.6
. If this is the case, you've to upgrade your Gson
lib. The static method JsonParser.parseString
is added in version 2.8.6
. Checkout the change log.
For Maven, use:
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.6</version>
</dependency>
For Gradle, use:
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.6'
For SBT, use:
libraryDependencies += "com.google.code.gson" % "gson" % "2.8.6"
For Ivy, use:
<dependency org="com.google.code.gson" name="gson" rev="2.8.6"/>
For Grape, use:
@Grapes(
@Grab(group='com.google.code.gson', module='gson', version='2.8.6')
)
For Leiningen, use:
[com.google.code.gson/gson "2.8.6"]
For Buildr, use:
'com.google.code.gson:gson:jar:2.8.6'