koraktor / steam-condenser

A multi-language library for querying the Steam Community, Source, GoldSrc servers and Steam master servers
https://koraktor.de/steam-condenser
Other
356 stars 67 forks source link

XML data could not be parsed: null [Java] #245

Closed afij closed 10 years ago

afij commented 10 years ago

I have been messing around with the API but I am halted before I can really try things out when I make a new SteamId object:

id = SteamId.create("FiJi");

I receive the following error when the application steps through the XMLData(String url) method somewhere in the document builder.

I have this profile's XML can be reached online (http://steamcommunity.com/id/fiji?xml=1) but cannot be translated properly. From what I have read the XML output is deprecated but things should still work. Any ideas? If you require more info just let me know.

koraktor commented 10 years ago

The given profile works flawlessly for me. This may probably caused by Steam sending errors (e.g. "internal server error") as HTML output instead of XML.

Maybe you can provide a full stacktrace of the exception.

afij commented 10 years ago

I have worked past this error (needed a jar) and have continued to venture into a seperate issue when working with GameInventory.

The app queries the Steam Web API to get grab /GetPlayerItems/ but warns;

04-30 16:36:49.244: I/dalvikvm(11184): Could not find method org.json.JSONObject.getNames, referenced from method com.github.koraktor.steamcondenser.steam.community.GameItem. 04-30 16:36:49.244: W/dalvikvm(11184): VFY: unable to resolve static method 13018: Lorg/json/JSONObject;.getNames (Lorg/json/JSONObject;)[Ljava/lang/String;

Further down into the stack there is a runtime exception:

04-30 16:36:54.834: E/AndroidRuntime(11184): FATAL EXCEPTION: AsyncTask #1 04-30 16:36:54.834: E/AndroidRuntime(11184): java.lang.RuntimeException: An error occured while executing doInBackground() 04-30 16:36:54.834: E/AndroidRuntime(11184): at android.os.AsyncTask$3.done(AsyncTask.java:278) 04-30 16:36:54.834: E/AndroidRuntime(11184): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273) 04-30 16:36:54.834: E/AndroidRuntime(11184): at java.util.concurrent.FutureTask.setException(FutureTask.java:124) 04-30 16:36:54.834: E/AndroidRuntime(11184): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307) 04-30 16:36:54.834: E/AndroidRuntime(11184): at java.util.concurrent.FutureTask.run(FutureTask.java:137) 04-30 16:36:54.834: E/AndroidRuntime(11184): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208) 04-30 16:36:54.834: E/AndroidRuntime(11184): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076) 04-30 16:36:54.834: E/AndroidRuntime(11184): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569) 04-30 16:36:54.834: E/AndroidRuntime(11184): at java.lang.Thread.run(Thread.java:856) 04-30 16:36:54.834: E/AndroidRuntime(11184): Caused by: java.lang.ClassCastException: java.lang.NoSuchMethodError cannot be cast to java.lang.RuntimeException 04-30 16:36:54.834: E/AndroidRuntime(11184): at com.github.koraktor.steamcondenser.steam.community.GameInventory.fetch(GameInventory.java:224) 04-30 16:36:54.834: E/AndroidRuntime(11184): at com.github.koraktor.steamcondenser.steam.community.GameInventory.(GameInventory.java:188) 04-30 16:36:54.834: E/AndroidRuntime(11184): at com.github.koraktor.steamcondenser.steam.community.tf2.TF2Inventory.(TF2Inventory.java:118) 04-30 16:36:54.834: E/AndroidRuntime(11184): at com.github.koraktor.steamcondenser.steam.community.GameInventory.create(GameInventory.java:136) 04-30 16:36:54.834: E/AndroidRuntime(11184): at com.github.koraktor.steamcondenser.steam.community.GameInventory.create(GameInventory.java:103) 04-30 16:36:54.834: E/AndroidRuntime(11184): at com.github.koraktor.steamcondenser.steam.community.GameInventory.create(GameInventory.java:86) 04-30 16:36:54.834: E/AndroidRuntime(11184): at com.example.testapi.Items$GetInventory.doInBackground(Items.java:124) 04-30 16:36:54.834: E/AndroidRuntime(11184): at com.example.testapi.Items$GetInventory.doInBackground(Items.java:1) 04-30 16:36:54.834: E/AndroidRuntime(11184): at android.os.AsyncTask$2.call(AsyncTask.java:264) 04-30 16:36:54.834: E/AndroidRuntime(11184): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305) 04-30 16:36:54.834: E/AndroidRuntime(11184): ... 5 more

Not sure if the two things are related but this is my current challenge! Any help would be welcome.

koraktor commented 10 years ago

That sounds like the the JSON library is also missing.

I don't know if this is possible for Android, but you should use Maven or a compatible build environment to get all dependencies right. Otherwise have a look at the pom.xml.

afij commented 10 years ago

I have added the JSON library to my build path and have noticed that no other JSONObject methods that appear before .getNames() have this problem.

I have looked into/attempted to add maven into my android project but I haven't been able to get anything to work properly. I will keep looking around for a solution.

koraktor commented 10 years ago

Currently Steam Condenser depends on this slightly outdated version of JSON. I don't know if the newer ones are compatible, so you might try to use this one explicitly.

afij commented 10 years ago

I believe I found the problem. The org.json included with android does NOT contain that method (http://developer.android.com/reference/org/json/JSONObject.html) while the one steam-condenser does have it. This means for some reason my project is not referencing the correct library when compiling.

I cannot get my project to point to the correct one though. I have tried to add the jar you just gave me to the build path but it still does not get the right one when I import it into a class for testing.

koraktor commented 10 years ago

I have little experience developing Android apps, so I don't know if there's a way to override system libraries with custom JARs. Maybe there's some way to control the classpath during runtime.

afij commented 10 years ago

I have corrected all the errors by tediously adding steam-condenser to my own package to point them in the right direction.

Next question I have is for creating a GameInventory? Does creating an inventory for something like TF2 normally take up alot of memory. I'm able list off items from an inventory but when I test on mobile I run into memory issues. Looks like it's from how deep the querying goes inside itself.

Thanks for all the help so far!

----- Reply message ----- From: "Sebastian Staudt" notifications@github.com To: "koraktor/steam-condenser" steam-condenser@noreply.github.com Cc: "fiji42nk" fiji-42nk@hotmail.com Subject: [steam-condenser] XML data could not be parsed: null Java Date: Thu, May 1, 2014 10:54 AM

I have little experience developing Android apps, so I don't know if there's a way to override system libraries with custom JARs. Maybe there's some way to control the classpath during runtime.


Reply to this email directly or view it on GitHub: https://github.com/koraktor/steam-condenser/issues/245#issuecomment-41917044

koraktor commented 10 years ago

Sorry for the late response.

Especially the item schema might require a bit of memory. The raw item schema of TF2 is 3.6MB for example. The raw data is not explicitly held in memory by Steam Condenser, but must be parsed to JSON objects and additionally parsed to Steam Condenser's GameItemSchema. I don't have any numbers, but I'd assume that this should be possible on a modern Android device.

I'll close this, but feel free to open a new issue if memory is still a problem for you.