Tuesday, 26 July 2022

Xamarin Android Library Binding - Class does not contain a definition

Xamarin Play Core (the package for reviews & tasks needed to launch reviews) split for v2.0.0 into individual packages, so I'm trying to create a Xamarin Android bindings library for the review and tasks. I successfully got tasks working but I am getting this error for the review nuget when it should just work according to their docs. It might be a simple fix, I thought I just had to add these lines in the metadata file but that didn't fix it:

<attr path="/api/package[@name='com.google.android.play.core.review']/class[@name='IReviewManager']" name="extends">Java.Lang.Object</attr> 
<attr path="/api/package[@name='com.google.android.play.core.review.testing']/class[@name='FakeReviewManager']" name="extends">Java.Lang.Object</attr>

Here's the error I get:

...PlayCoreUpdateTest/PlayCoreUpdateTest.Android/InAppReviewService.cs(35,35): Error CS1061: 'FakeReviewManager' does not contain a definition for 'LaunchReviewFlow' and no accessible extension method 'LaunchReviewFlow' accepting a first argument of type 'FakeReviewManager' could be found (are you missing a using directive or an assembly reference?) (CS1061) (PlayCoreUpdateTest.Android)

Screenshot of the error described above I know the magic happens in the generated api.xml file, so here's a code dump of it. In there I do see the FakeReviewManager, but I don't see the RequestReviewFlow, when it should be there

It's still a work in progress but those are the only remaining issues, here's the GitHub code. I watched Jonathan Dick's video on creating Xamarin library bindings and tried the Microsoft FAQ options here too

I know my functions in InAppReviewService.cs are correct because that's what the official docs tell us to use, and it's what we were using before for v1.10.

Update: I did notice there's an api.xml.class-parse file beside api.xml, that does contain the missing method LaunchReviewFlow inside the FakeReviewManager class. I'm trying to understand why it didn't show up in api.xml. Here's a dump for that one. I did notice that in the api.xml.class-parse file, there are these lines

return="com.google.android.play.core.tasks.Task&lt;java.lang.Void&gt;"
jni-return="Lcom/google/android/play/core/tasks/Task&lt;Ljava/lang/Void;&gt;;"
...
jni-signature="(Landroid/app/Activity;Lcom/google/android/play/core/review/ReviewInfo;)Lcom/google/android/play/core/tasks/Task;"

which that the v2.0 AAB file points to a play core tasks library even though it recommends pointing to the GMS version of Tasks Screenshot of above described

To counter that, I tried to add variations of these lines, but none of that helped:

  <add-node path="/api/package[@name='com.google.android.play.core.review.testing']/class[@name='FakeReviewManager']">
    <method abstract="false" deprecated="not deprecated" final="false" name="launchReviewFlow" jni-signature="(Landroid/app/Activity;Lcom/google/android/play/core/review/ReviewInfo;)Lcom/google/android/gms/tasks/Task;" bridge="false" native="false" return="com.google.android.gms.tasks.Task&lt;java.lang.Void&gt;" jni-return="Lcom/google/android/gms/tasks/Task&lt;Ljava/lang/Void;&gt;;" static="false" synchronized="false" synthetic="false" visibility="public" return-not-null="true">
        <parameter name="p0" type="android.app.Activity" jni-type="Landroid/app/Activity;" not-null="true" />
        <parameter name="reviewInfo" type="com.google.android.play.core.review.ReviewInfo" jni-type="Lcom/google/android/play/core/review/ReviewInfo;" not-null="true" />
    </method>
    <method abstract="false" deprecated="not deprecated" final="false" name="requestReviewFlow" jni-signature="()Lcom/google/android/gms/tasks/Task;" bridge="false" native="false" return="com.google.android.gms.tasks.Task&lt;com.google.android.play.core.review.ReviewInfo&gt;" jni-return="Lcom/google/android/gms/tasks/Task&lt;Lcom/google/android/play/core/review/ReviewInfo;&gt;;" static="false" synchronized="false" synthetic="false" visibility="public" return-not-null="true" />
  </add-node>


from Xamarin Android Library Binding - Class does not contain a definition

No comments:

Post a Comment