Skip to content

Exception when instantiating android.net.nsd.NsdManager #9211

@matthew798

Description

@matthew798

Environment
✔ Component nativescript has 7.2.0 version and is up to date.
⚠ Update available for component @nativescript/core. Your current version is 7.1.4 and the latest available version is 7.2.1.
✖ Component @nativescript/ios is not installed.
✔ Component @nativescript/android has 7.0.1 version and is up to date.

Describe the bug
An exception is thrown when trying to create an instance of android.net.nds.NsdManager.

Error: java.lang.Exception: Failed resolving constructor for class 'android.net.nsd.NsdManager' with 0 parameters. Check the number and type of arguments.

To Reproduce
Attempt to create an instance of android.net.nds.NsdManager:

const manager = new android.net.nsd.NsdManager();

Expected behavior
The class is instantiated correctly.

Sample project
Just run tns create test and add const manager = new android.net.nsd.NsdManager(); anywhere that will run when the app is launched.

Additional context
The class definition in android-platform-17.d.ts is:

export class NsdManager extends java.lang.Object {
				public static class: java.lang.Class<android.net.nsd.NsdManager>;
				public static ACTION_NSD_STATE_CHANGED: string;
				public static EXTRA_NSD_STATE: string;
				public static NSD_STATE_DISABLED: number;
				public static NSD_STATE_ENABLED: number;
				public static PROTOCOL_DNS_SD: number;
				public static FAILURE_INTERNAL_ERROR: number;
				public static FAILURE_ALREADY_ACTIVE: number;
				public static FAILURE_MAX_LIMIT: number;
				public discoverServices(param0: string, param1: number, param2: android.net.nsd.NsdManager.DiscoveryListener): void;
				public stopServiceDiscovery(param0: android.net.nsd.NsdManager.DiscoveryListener): void;
				public resolveService(param0: android.net.nsd.NsdServiceInfo, param1: android.net.nsd.NsdManager.ResolveListener): void;
				public unregisterService(param0: android.net.nsd.NsdManager.RegistrationListener): void;
				public registerService(param0: android.net.nsd.NsdServiceInfo, param1: number, param2: android.net.nsd.NsdManager.RegistrationListener): void;
			}

Which does not have the following constructor from the android SDK class definition:

        public NsdManager(Context context, INsdManager service) {
            mService = service;
            mContext = context;
            init();
        }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions