please check the following error while running the BluetoothLEExplorer.Droid project from http://developer.xamarin.com/content/BluetoothLEExplorer/.
D:\robotics programming\ys u\BluetoothLEExplorer_2\BluetoothLEExplorer.Droid\obj\Debug\android\src\bluetoothleexplorer\droid\ui\controls\ScanButton.java(3,3): Error: error: no suitable constructor found for Button(Context,AttributeSet,int,int)
super (p0, p1, p2, p3);
constructor Button.Button(Context) is not applicable
(actual and formal argument lists differ in length)
constructor Button.Button(Context,AttributeSet) is not applicable
(actual and formal argument lists differ in length)
constructor Button.Button(Context,AttributeSet,int) is not applicable
(actual and formal argument lists differ in length)
(BluetoothLEExplorer.Droid)

this is on line 43 in ScanButton.java file in the controls directory.
the following is ScanButton.java file

package bluetoothleexplorer.droid.ui.controls;


public class ScanButton
    extends android.widget.Button
    implements
        mono.android.IGCUserPeer
{
    static final String __md_methods;
    static {
        __md_methods = 
            "";
        mono.android.Runtime.register ("BluetoothLEExplorer.Droid.UI.Controls.ScanButton, Xamarin.Robotics.BluetoothLEExplorer.Droid, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", ScanButton.class, __md_methods);
    }


    public ScanButton (android.content.Context p0) throws java.lang.Throwable
    {
        super (p0);
        if (getClass () == ScanButton.class)
            mono.android.TypeManager.Activate ("BluetoothLEExplorer.Droid.UI.Controls.ScanButton, Xamarin.Robotics.BluetoothLEExplorer.Droid, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", "Android.Content.Context, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065", this, new java.lang.Object[] { p0 });
    }


    public ScanButton (android.content.Context p0, android.util.AttributeSet p1) throws java.lang.Throwable
    {
        super (p0, p1);
        if (getClass () == ScanButton.class)
            mono.android.TypeManager.Activate ("BluetoothLEExplorer.Droid.UI.Controls.ScanButton, Xamarin.Robotics.BluetoothLEExplorer.Droid, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", "Android.Content.Context, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065:Android.Util.IAttributeSet, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065", this, new java.lang.Object[] { p0, p1 });
    }


    public ScanButton (android.content.Context p0, android.util.AttributeSet p1, int p2) throws java.lang.Throwable
    {
        super (p0, p1, p2);
        if (getClass () == ScanButton.class)
            mono.android.TypeManager.Activate ("BluetoothLEExplorer.Droid.UI.Controls.ScanButton, Xamarin.Robotics.BluetoothLEExplorer.Droid, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", "Android.Content.Context, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065:Android.Util.IAttributeSet, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065:System.Int32, mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e", this, new java.lang.Object[] { p0, p1, p2 });
    }


    public ScanButton (android.content.Context p0, android.util.AttributeSet p1, int p2, int p3) throws java.lang.Throwable
    {
        super (p0, p1, p2, p3);
        if (getClass () == ScanButton.class)
            mono.android.TypeManager.Activate ("BluetoothLEExplorer.Droid.UI.Controls.ScanButton, Xamarin.Robotics.BluetoothLEExplorer.Droid, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", "Android.Content.Context, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065:Android.Util.IAttributeSet, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065:System.Int32, mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e:System.Int32, mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e", this, new java.lang.Object[] { p0, p1, p2, p3 });
    }

    java.util.ArrayList refList;
    public void monodroidAddReference (java.lang.Object obj)
    {
        if (refList == null)
            refList = new java.util.ArrayList ();
        refList.add (obj);
    }

    public void monodroidClearReferences ()
    {
        if (refList != null)
            refList.clear ();
    }
}

on line 43, you call this:

super (p0, p1, p2, p3);

meaning, you are trying to invoke the constructor of the super class (being Button) with those parameters.
those arguments are of the type(s):
android.content.Context p0, android.util.AttributeSet p1, int p2, int p3

as the stacktrace says: Button does not have a constructor that accepts those parameters.

the constructor is initialised in the current context so why the error on the specific line not above where the p0 starts .
how to solve it that the project compile and send no error while compiling?
thanks

"the constructor is initialised in the current context" what do you mean by that? in the class you are working in? if so, no, it isn't.
with super (p0, p1, p2, p3); you call the constructor of the super class, being: android.widget.Button

YOUR class does have a constructor that takes these parameters, this Button class does not. that is why the error occurs on exactly that line.

i changed it this way but does not work.

package bluetoothleexplorer.droid.ui.controls;


public class ScanButton
    extends android.widget.Button
    implements
        mono.android.IGCUserPeer
{
    static final String __md_methods;
    static {
        __md_methods = 
            "";
        mono.android.Runtime.register ("BluetoothLEExplorer.Droid.UI.Controls.ScanButton, Xamarin.Robotics.BluetoothLEExplorer.Droid, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", ScanButton.class, __md_methods);
    }


    public ScanButton (android.content.Context p0) throws java.lang.Throwable
    {
        super (p0);
        if (getClass () == ScanButton.class)
            mono.android.TypeManager.Activate ("BluetoothLEExplorer.Droid.UI.Controls.ScanButton, Xamarin.Robotics.BluetoothLEExplorer.Droid, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", "Android.Content.Context, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065", this, new java.lang.Object[] { p0 });
    }


    public ScanButton (android.content.Context p0, android.util.AttributeSet p1) throws java.lang.Throwable
    {
        super (p0, p1);
        if (getClass () == ScanButton.class)
            mono.android.TypeManager.Activate ("BluetoothLEExplorer.Droid.UI.Controls.ScanButton, Xamarin.Robotics.BluetoothLEExplorer.Droid, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", "Android.Content.Context, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065:Android.Util.IAttributeSet, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065", this, new java.lang.Object[] { p0, p1 });
    }


    public ScanButton (android.content.Context p0, android.util.AttributeSet p1, int p2) throws java.lang.Throwable
    {
        super (p0, p1, p2);
        if (getClass () == ScanButton.class)
            mono.android.TypeManager.Activate ("BluetoothLEExplorer.Droid.UI.Controls.ScanButton, Xamarin.Robotics.BluetoothLEExplorer.Droid, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", "Android.Content.Context, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065:Android.Util.IAttributeSet, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065:System.Int32, mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e", this, new java.lang.Object[] { p0, p1, p2 });
    }


    public ScanButton (android.content.Context p0, android.util.AttributeSet p1, int p2, int p3) throws java.lang.Throwable
    {
        super (android.content.Context, android.util.AttributeSet, int, int);
        if (getClass () == ScanButton.class)
            mono.android.TypeManager.Activate ("BluetoothLEExplorer.Droid.UI.Controls.ScanButton, Xamarin.Robotics.BluetoothLEExplorer.Droid, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", "Android.Content.Context, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065:Android.Util.IAttributeSet, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065:System.Int32, mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e:System.Int32, mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e", this, new java.lang.Object[] { p0, p1, p2, p3 });
    }

    java.util.ArrayList refList;
    public void monodroidAddReference (java.lang.Object obj)
    {
        if (refList == null)
            refList = new java.util.ArrayList ();
        refList.add (obj);
    }

    public void monodroidClearReferences ()
    {
        if (refList != null)
            refList.clear ();
    }
}

set the constructor in such a way that it does work in the cuurent context for all its arguments.
thanks

.....

do you have any experience in basic Java programming using inheritance?

you just call a constructor, and don't tell it what values you pass to it, just what type the parameters should have. and, yet again: your parent class doesn't have a constructor that takes those arguments.

<<EDIT>>

personally, I would expect it to work like you had originally. but, according to your error message, there isn't such a constructor. so: check your dependencies, make sure you know what version you are working with, and that the error message you show is actually based on the code you've shown here.

Edited 1 Year Ago by stultuske

well, to me, it looks to be, but if it gives an exception, there's bound to be something wrong with it, hence, the exception.

This article has been dead for over six months. Start a new discussion instead.