Skip to content

Unable to solve "The method {method} was removed because the Java parameter type {type} could not be found" #10668

@nk-alex

Description

@nk-alex

Android framework version

net10.0-android (Preview)

Affected platform version

VS 2026 18.1.1, net10.0-android

Description

My Problem

I'm trying to create an Android binding around a native library I would like to use in my .net maui application. To start this process, I've created an Android Library (Android studio) and added the gradle dependencies I needed:

dependencies {
    implementation("com.stripe:stripeterminal-taptopay:5.1.1")
    implementation("com.stripe:stripeterminal-core:5.1.1")
}

After that, I've created a java class consuming those dependencies. Here one of the problematic methods:

public static void initialize(@NonNull Application application,
            @NonNull com.stripe.stripeterminal.external.callable.ConnectionTokenProvider tokenProvider,
            @NonNull com.stripe.stripeterminal.external.callable.TerminalListener listener) throws TerminalException {
       //My code using the native library
    }

The Android Library is building as expected.


The second step, is to open Visual Studio and create a Android Java Binding Library consuming the Android Library compiled in the first step. To do so, I add reference to build.gradle.kts in project file like:

	<ItemGroup>
		<AndroidGradleProject Include="../../native/StripeAndroidBinding/build.gradle.kts">
			<ModuleName>dotnetbinding</ModuleName>
		</AndroidGradleProject>
	</ItemGroup>

And add information to Metadata.xml:

<metadata>
	<attr path="/api/package[@name='com.company.dotnetbinding']" name="managedName">StripeAndroidBinding</attr>
</metadata>

Nothing else. At this point, the Android Java Binding Library is compiling.


The third step is consuming my Android Java Binding Library from my .net maui project. I can use most of the methods, but, the problem is that some methods (like initialize) are just missing from my Binding. By taking a look at (wiki), I have followed the steps to determine my problem:

  1. Search for my method initialize inside api.xml.class-parse. Seems that the method is here:
<method
        abstract="false"
        deprecated="not deprecated"
        final="false"
        name="initialize"
        native="false"
        return="void"
        jni-return="V"
        static="true"
        synchronized="false"
        visibility="public"
        bridge="false"
        synthetic="false"
        jni-signature="(Landroid/app/Application;Lcom/stripe/stripeterminal/external/callable/ConnectionTokenProvider;Lcom/stripe/stripeterminal/external/callable/TerminalListener;)V">
        <parameter
          name="application"
          type="android.app.Application"
          jni-type="Landroid/app/Application;"
          not-null="true" />
        <parameter
          name="tokenProvider"
          type="com.stripe.stripeterminal.external.callable.ConnectionTokenProvider"
          jni-type="Lcom/stripe/stripeterminal/external/callable/ConnectionTokenProvider;"
          not-null="true" />
        <parameter
          name="listener"
          type="com.stripe.stripeterminal.external.callable.TerminalListener"
          jni-type="Lcom/stripe/stripeterminal/external/callable/TerminalListener;"
          not-null="true" />
        <exception
          name="com/stripe/stripeterminal/external/models/TerminalException"
          type="com.stripe.stripeterminal.external.models.TerminalException"
          type-generic-aware="com.stripe.stripeterminal.external.models.TerminalException" />
      </method>
  1. Search for my method in api.xml. Seems that api.xml does not contain the definition. So, following the wiki, I'm at ApiXmlAdjuster.

  2. Since I'm at ApiXmlAdjuster, the next step is to take a look at my java-resolution-report.log. Following what @jpobst said here, I'm just looking at first cycle:

==== Cycle 1 ====

The method '[Method] void initialize(android.app.Application application, com.stripe.stripeterminal.external.callable.ConnectionTokenProvider tokenProvider, com.stripe.stripeterminal.external.callable.TerminalListener listener)' was removed because the Java parameter type 'com.stripe.stripeterminal.external.callable.ConnectionTokenProvider' could not be found.
The method '[Method] void initialize(android.app.Application application, com.stripe.stripeterminal.external.callable.ConnectionTokenProvider tokenProvider, com.stripe.stripeterminal.external.callable.TerminalListener listener)' was removed because the Java parameter type 'com.stripe.stripeterminal.external.callable.TerminalListener' could not be found.
The class '[Class] com.company.dotnetbinding.TapToPayImplementation.1' was removed because the Java implemented interface type 'com.stripe.stripeterminal.external.callable.DiscoveryListener' could not be found.
  1. Just in case, by using a java decompiler on stripeterminal-external-5.1.1.aar, I can see TerminalListener, ConnectionTokenProvider and DiscoveryListener exist as interfaces. For instance, TerminalListener looks like this:
package com.stripe.stripeterminal.external.callable;

import com.stripe.stripeterminal.external.models.ConnectionStatus;
import com.stripe.stripeterminal.external.models.PaymentStatus;
import kotlin.Metadata;
import kotlin.jvm.internal.Intrinsics;
import org.jetbrains.annotations.NotNull;

@Metadata(mv = {1, 9, 0}, k = 1, xi = 48, d1 = {"\000\034\n\002\030\002\n\002\020\000\n\000\n\002\020\002\n\000\n\002\030\002\n\000\n\002\030\002\n\000\bf\030\0002\0020\001J\020\020\002\032\0020\0032\006\020\004\032\0020\005H\026J\020\020\006\032\0020\0032\006\020\004\032\0020\007H\026\001\000\002\006\n\004\b!0\001\006\b\006\001"}, d2 = {"Lcom/stripe/stripeterminal/external/callable/TerminalListener;", "", "onConnectionStatusChange", "", "status", "Lcom/stripe/stripeterminal/external/models/ConnectionStatus;", "onPaymentStatusChange", "Lcom/stripe/stripeterminal/external/models/PaymentStatus;", "kmpcore_sdk_terminal-external-models_public"})
public interface TerminalListener {
  default void onConnectionStatusChange(@NotNull ConnectionStatus status) {
    Intrinsics.checkNotNullParameter(status, "status");
  }
  
  default void onPaymentStatusChange(@NotNull PaymentStatus status) {
    Intrinsics.checkNotNullParameter(status, "status");
  }
}
  1. I have also used the java decompiler to check my .aar generated in first step and the initialize method is there.

What I've tried

  1. Changing initialize parameters to abstract classes implementing the original interfaces. (Trick doesn't work)
  2. Adding com.stripe:stripeterminal-external dependency into my Android Library project build.gradle.kts. (The same result as before adding it)
  3. Adding reference to com.stripe.stripeterminal.external.aar into my Android Java Binding Library project:
	<ItemGroup>
		<AndroidGradleProject Include="../../native/StripeAndroidBinding/build.gradle.kts">
			<ModuleName>dotnetbinding</ModuleName>
		</AndroidGradleProject>
		<AndroidLibrary Include="../../../../stripeterminal-external-5.1.1.aar" Visible="true"/>
	</ItemGroup>

But this generates 30+ errors like:

...
error CS0738: 'TapToPayUxConfiguration.ITapZone.Right.Creator' does not implement interface member 'IParcelableCreator.CreateFromParcel(Parcel?)'. 'TapToPayUxConfiguration.ITapZone.Right.Creator.CreateFromParcel(Parcel)' cannot implement 'IParcelableCreator.CreateFromParcel(Parcel?)' because it does not have the matching return type of 'Object'.

error CS0738: 'TapToPayUxConfiguration.ITapZone.Right.Creator' does not implement interface member 'IParcelableCreator.NewArray(int)'. 'TapToPayUxConfiguration.ITapZone.Right.Creator.NewArray(int)' cannot implement 'IParcelableCreator.NewArray(int)' because it does not have the matching return type of 'Object[]'.
....

Also is generating warnings like:

...
The "Com.Stripe.Stripeterminal.External.Models.TerminalErrorCode.Companion" has been omitted due to a duplicate nested type name. (Java type: "com.stripe.stripeterminal.external.models.TerminalErrorCode")
...

And java-resolution-report doesn't look good:

java-resolution-report.log


I'm really stuck right now I would really appreciate some help here. I'm running out of ideas.

Steps to Reproduce

  1. Create Android Library project (Android studio) using the native library.
  2. Create Android Java Binding Library referencing this Android Library project.
  3. Create .net maui application referencing this Android Java Binding Library.
  4. I can compile and access all methods but a couple of them that request parameters of unresolved types from the native library.

Did you find any workaround?

No workaround found

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triageIssues that need to be assigned.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions