Cannot namespace 'android' in windows


#1

hi, every one.
I am building nativescript app now.
I am going to add dropdown menu plugin in my project.
I installed npm install nativescript-dropdown-menu.
but when I compiling, I met 'cannot namespace ‘android’ ’ error.
How to solve this problem?
Please let me know the solve way.

thanks.


#2

Can you paste the error here, there’s likely more context to the error. Possibly a TypeScript issue which is easily fixable, but no way to tell without the full error here. Thanks :slight_smile:


#3

To add drop down menu,I executed follow command below.
tns plugin add nativescript-drop-down
npm install tns-platform-declarations --save-dev
tns run android.

but I met follow errors below.

node_modules/nativescript-drop-down/drop-down.d.ts(40,14): error TS2304: Cannot find name ‘UILabel’.
node_modules/nativescript-drop-down/drop-down.d.ts(41,18): error TS2503: Cannot find namespace ‘android’.
TypeScript compiler failed with exit code 1

Could you please help me?
Thanks:slight_smile:


#4

Yea those are just TS errors. You can bypass them by setting
noEmitOnError:false in your tsconfig.json.

The typing file for that plugin needs some tweaks, I edited it myself in my
apps to not have to bypass the compiler.


#5

Thanks,
in tnsconfig.json file, I did set noEmitOnError:false;
the error is disappear, but I cannot add dropdon menu in my project.

////projectdeel.html

<DropDown #dd backroundColor=“red” [items]=“items” [selectedIndex]=“selectedIndex”
(selectedIndexChanged)=“onchange($event)” (opened)="onopen()"
row=“0” colSpan=“2”>


<TextField [text]=“selected” row=“1” col=“1” >

//////projectdeel.ts

import { SelectedIndexChangedEventData } from “nativescript-drop-down”;

export class ProjectdeelComponent implements OnInit{

public selectedIndex = 1;
public items: Array<string>;
constructor(private page:Page,private router:Router){
    this.items = [];
    for (var i = 0; i < 5; i++) {
        this.items.push("data item " + i);
    }
}

… …

 public onchange(args: SelectedIndexChangedEventData) {
    console.log(`Drop Down selected index changed from ${args.oldIndex} to ${args.newIndex}`);
}

public onopen() {
    console.log("Drop Down opened.");
}

}

Please help me!!!:relaxed:


#6

If angular you’ll need to use registerElement() for the plugin. Check out
the check box plugin on my repo for a sample. It’s in the NS docs but I
forget where. On phone now or I’d send it. Let me know if you can’t find it.