1

IPC between 2 Android apps developed using Xamarin.Android is throwing an exception at the Mon Framework layer with the below message. Any help in this regards is highly appreciated:

System.NotSupportedException: Unable to activate instance of type ClientApplication.AddtionServiceConnnection from native handle 0xbf950b2c (key_handle 0x45f1f2d). ---> System.MissingMethodException: No constructor found for ClientApplication.AddtionServiceConnnection::.ctor(System.IntPtr, Android.Runtime.JniHandleOwnership) ---> Java.Interop.JavaLocationException: Exception of type 'Java.Interop.JavaLocationException' was thrown.
   --- End of inner exception stack trace ---
  at Java.Interop.TypeManager.CreateProxy (System.Type type, System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00054] in <e975227ac8644a30bb0866117325de0d>:0 
  at Java.Interop.TypeManager.CreateInstance (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type targetType) [0x00111] in <e975227ac8644a30bb0866117325de0d>:0 
   --- End of inner exception stack trace ---

Below is my AIDL contents:

package com.ServerApp.AddFunction;

interface IAdditionService
{
    int Add(in int n1,in int n2);
}


public class AddtionServiceConnnection :IAdditionServiceStub, IServiceConnection
{

    public void Dispose()
    {
        //throw new NotImplementedException();
    }

    public IAdditionService AddtionService { get; private set; } 

    public void OnServiceConnected(ComponentName name, IBinder service)
    {
        AddtionService = IAdditionServiceStub.AsInterface(service);
        MainActivity.Instance.MyService = AddtionService;
        MainActivity.Instance.IsBound = AddtionService != null;
    }

    public void OnServiceDisconnected(ComponentName name)
    {
        MainActivity.Instance.MyService = null;
        MainActivity.Instance.IsBound = false;
    }

    public override int Add(int n1, int n2)
    {
        return AddtionService.Add(n1,n2);
    }

    public IntPtr Handle { get; }
}
}

Below is the android manifest of the application providing the service:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.ServerApp.AddProgram" android:versionCode="1" android:versionName="1.0" android:installLocation="auto">
    <uses-sdk android:minSdkVersion="21" />
    <application android:allowBackup="true" android:label="@string/app_name"></application>
  <service android:name=".AdditionService"/>
</manifest>
sorak
  • 2,607
  • 2
  • 16
  • 24
Abishek
  • 11
  • 4
  • `System.MissingMethodException: No constructor found for ClientApplication.AddtionServiceConnnection` – Felix D. Mar 08 '18 at 07:51
  • But default constructor of AddtionServiceConnection is getting invoked which in-turn invokes IAdditionServiceStub class constructor so not able to understand where the exception is being thrown – Abishek Mar 08 '18 at 10:43
  • I guess he is looking for more than a default constructor .. – Felix D. Mar 08 '18 at 10:45
  • I was able to find the fix and the issue all credits to the information found in the below link. – Abishek Mar 08 '18 at 14:06
  • https://stackoverflow.com/questions/26573627/no-constructor-found-for-system-intptr-android-runtime-jnihandleownership In My case in AdditionServiceConnection I had declared the below property commenting which fixed the issue for me. public IntPtr Handle { get; } – Abishek Mar 08 '18 at 14:18

0 Answers0