1
votes

Trying to deploy my first libgdx game on the web and ran the command ./gradlew html:dist in the android studio terminal but I keep getting the following error

[ERROR] Line 51: No source code is available for type org.json.simple.parser.JSONParser; did you forget to inherit a required module?

[ERROR] Line 54: No source code is available for type org.json.simple.JSONObject; did you forget to inherit a required module?

[ERROR] Line 58: No source code is available for type org.json.simple.JSONArray; did you forget to inherit a required module? [ERROR] Aborting compile due to errors in some input files :html:compileGwt FAILED

After looking online, I've tried resolving this issue by including this line

<inherits name="com.google.gwt.json.JSON" />

in MyGdxGame.gwt.xml file, an idea which I got from here. But that doesn't seem to have resolved the issue. Any other ideas? This is what my file looks like

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit trunk//EN"    
"http://google-web-toolkit.googlecode.com/svn/trunk/distro-source/core/src/gwt-module.dtd">

<module>
    <source path="com/mygdx/fierykirby/gamedev" />
    <inherits name="com.google.gwt.json.JSON" />
    <inherits name="com.google.gwt.http.HTTP" />
</module>
1
Instead using org.json.simple.parser.JSONParser/JSONObject/JSONArray you might use com.google.gwt.json.client.JSONParser, JSONObject and JSONArray. I am not quite sure if classes on org.json.simple will work with GWT. It is saying that it can not find the sources of a library (GWT does need the sources to translate it to Javascript). - Euclides
Can you change the order of inherits, HTTP first and JSON at the last? I remember this one just because of the order issue! - N00b Pr0grammer
Please stop saying whatever thing goes into your mind. This has nothing to do with order. - zakaria amine

1 Answers

0
votes

If you inherit com.google.gwt.user.User, you should be able to use the JSON libraries that come with GWT. That should handle all your JSON needs. No need to go outside of GWT for that.

*.gwt.xml:

<inherits name='com.google.gwt.user.User'/>

*.java:

import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONParser;