Wikidata-Toolkit icon indicating copy to clipboard operation
Wikidata-Toolkit copied to clipboard

Port to Android

Open nicolas-raoul opened this issue 6 years ago • 9 comments

As a developer of the Commons Android app, I would like to use a Java library to add P18 (image) statements from the app (the app directs the user to nearby points of interest missing a P18 to take pictures of them).

It would be great if there were an Android-compatible small library that allowed that. If there is already one that I have missed, please let me know, thanks :-)

nicolas-raoul avatar Apr 24 '18 07:04 nicolas-raoul

It would be great indeed to make WikidataToolkit work with Android. I am not much familiar with it. It would be amazing if you could do a pull request for this.

Tpt avatar Apr 24 '18 08:04 Tpt

The new 0.9.0 release should work with Android. @nicolas-raoul If you have some time may you test?

Tpt avatar Aug 02 '18 11:08 Tpt

@Tpt Is there any documentation to easily get started on it :)

maskaravivek avatar Aug 03 '18 12:08 maskaravivek

@maskaravivek The documentation is here with links to example: https://www.mediawiki.org/wiki/Wikidata_Toolkit

Feel free to ask anything you need :-)

Tpt avatar Aug 03 '18 13:08 Tpt

About the WikidataToolkit dependencies: we could definitely consider to move from one JSON deserialization library or HTTP client to an other if it makes the Android use case much more appealing.

Tpt avatar Aug 03 '18 13:08 Tpt

A little late to the party here...but I am seeing failure on Android whereas toolkit works fine under Spring.

Am receiving null for a well known QID (any qid actually) with following code:

    WikibaseDataFetcher wbdf = getWikibaseDataFetcher("en");
    EntityDocument edoc = wbdf.getEntityDocument(qid);

The QID is 26303...Thales a pre-socratic philosopher. Any ideas of why it is failing?

mikeklein avatar Jun 10 '20 05:06 mikeklein

@mikeklein Hi! Sorry for the problem. It's strange. If the API call where failing (no network, invalid host...), the code would have returned an exception instead. Are you sure that your qid is valid and you are reaching Wikidata (and not test Wikidata, Commons...)? It's hard to get a good understanding of what your code is doing from just two lines of code.

Tpt avatar Jun 10 '20 06:06 Tpt

Just to be sure we are on the same page, the qid should be a string containing "Q36303", not "36303".

wetneb avatar Jun 10 '20 07:06 wetneb

Hello and thanks for quick response. I just found that the problem "magickally" went away an hour ago.

I did debug earlier and it was throwing following error btw:

Error when reading JSON for entity Q80612: com.fasterxml.jackson.databind.exc.ValueInstantiationException: Cannot construct instance of org.wikidata.wdtk.datamodel.implementation.TermImpl, problem: Exception from call site #30 bootstrap method at [Source: UNKNOWN; line: -1, column: -1] (through reference chain: org.wikidata.wdtk.datamodel.implementation.ItemDocumentImpl["labels"]→java.util.LinkedHashMap["en"])

And yes the Q was part of string param value...thanks.

mikeklein avatar Jun 10 '20 09:06 mikeklein