ouya-csharp icon indicating copy to clipboard operation
ouya-csharp copied to clipboard

OuyaEncryptionHelper.DecryptReceiptResponse NoSuchMethodError

Open mkilling opened this issue 11 years ago • 3 comments

This causes a NoSuchMethodError at runtime:

var helper = new OuyaEncryptionHelper();
helper.DecryptReceiptResponse(jsonObject, publicKey);

The reason seems to be a signature mismatch: OuyaEncryptionHelper.DecryptReceiptResponse is defined with the first parameter being a org.json.JSONObject but this is overridden to become a java.lang.Object. This was done in f6e8084, in lines 49-50 of Metadata.xml:

<attr path= "//parameter[@type='org.json.JSONObject']" name="type">java.lang.Object</attr>
<attr path= "//parameter[@type='org.json.JSONArray']" name="type">java.lang.Object</attr>

The comment suggests it's only a temporary workaround. Could you explain why you had to override the JSON types?

mkilling avatar Jun 10 '13 18:06 mkilling

Xamarin.Android does not yet expose the org.json.JsonObject type for C# to use, therefore the parameter had to be changed. I had not been able to fully test these methods at runtime as my OUYA is still to be received and the ODK no longer works on the Nexus 7 since ODK 1.0.2.

To work around the missing JSON types in Xamarin.Android, Aranda contributed purchaseutils.jar which implements the purchasing side in a manner that Xamarin understands.

KonajuGames avatar Jun 10 '13 20:06 KonajuGames

I'm working with Xamarin.Android 4.7 and it seems that org.json.JsonObject is working. I just removed the two lines from Metadata.xml.

Using the methods of purchaseutils.jar produces segfaults in some JNI code for me. I wasn't yet able to pinpoint what exactly goes wrong but I'll let you know once I found something.

mkilling avatar Jun 10 '13 21:06 mkilling

Ah yes. They were adding the Json types in 4.7.

KonajuGames avatar Jun 10 '13 21:06 KonajuGames