PeterStaev / NativeScript-Drop-Down

A NativeScript DropDown widget.
Apache License 2.0
105 stars 65 forks source link

Cannot read property 'getAdapter' of undefined #170

Closed wendt88 closed 6 years ago

wendt88 commented 6 years ago

get this error on Android since version 3.2.2 + 3.2.4 of dropdown, downgrade to 3.2.1 solved it:

JS: ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'getAdapter' of undefined
JS: TypeError: Cannot read property 'getAdapter' of undefined
JS:     at DropDown.refresh (file:///data/data/<app>/files/app/tns_modules/nativescript-drop-down/drop-down.js:75:21)
JS:     at resetChildrenRefreshes (file:///data/data/<app>/files/app/tns_modules/nativescript-orientation/orientation.js:310:9)
JS:     at localCallback (file:///data/data/<app>/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js:75:29)
JS:     at GridLayout.LayoutBaseCommon.eachChildView (file:///data/data/<app>/files/app/tns_modules/tns-core-modules/ui/layouts/layout-base-common.js:125:26)
JS:     at GridLayout.ViewCommon.eachChild (file:///data/data/<app>/files/app/tns_modules/tns-core-modules/ui/core/view/view-common.js:699:14)
JS:     at localCallback (file:///data/data/<app>/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js:77:19)
JS:     at GridLayout.LayoutBaseCommon.eachChildView (file:///data/data/<app>/files/app/tns_modules/tns-core-modules/ui/layouts/layout-base-common.js:125:26)
JS:     at GridLayout.ViewCommon.eachChild (file:///data/data/<app>/files/app/tns_modules/tns-core-modules/ui/core/view/view-common.js:699:14)
JS:     at localCallback (file:///data/data/<app>/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js:77:19)
JS:     at GridLayout.LayoutBaseCommon.eachChildView (file:///data/data/<app>/files/app/tns_modules/tns-core-modules/ui/layouts/layout-base-common.js:125:26)
JS:     at GridLayout.ViewCommon.eachChild (file:///data/data/<app>/files/app/tns_modules/tns-core-modules/ui/core/view/view-common.js:699:14)
JS:     at localCallback (file:///data/data/<app>/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js:77:19)
JS:     at ProxyViewContainer.LayoutBaseCommon.eachChildView (file:///data/data/<app>p/files/app/tns_modules/tns-core-modules/ui/layouts/layout-base-common.js:125:26)
JS:     at ProxyViewContainer.ViewCommon.eachChild (file:///data/data/<app>/files/app/tns_modules/tns-core-modules/ui/core/view/view-common.js:699:14)
JS:     at localCallback (file:///data/data/<app>/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js:77:19)

packages:

"dependencies": {
    "@angular/animations": "^5.2.7",
    "@angular/common": "^5.2.7",
    "@angular/compiler": "^5.2.7",
    "@angular/core": "^5.2.7",
    "@angular/forms": "^5.2.7",
    "@angular/http": "^5.2.7",
    "@angular/platform-browser": "^5.2.7",
    "@angular/platform-browser-dynamic": "^5.2.7",
    "@angular/router": "^5.2.7",
    "nativescript-angular": "~5.2.0",
    "nativescript-appavailability": "^1.3.1",
    "nativescript-drop-down": "^3.2.3",
    "nativescript-i18n": "^0.2.4",
    "nativescript-insomnia": "^1.2.1",
    "nativescript-intl": "^3.0.0",
    "nativescript-orientation": "^2.2.0",
    "nativescript-pulltorefresh": "^2.1.0",
    "nativescript-ui-listview": "^3.5.0",
    "reflect-metadata": "^0.1.12",
    "rxjs": "~5.5.2",
    "tns-core-modules": "^3.4.1",
    "zone.js": "^0.8.20"
  },
  "devDependencies": {
    "@angular/compiler-cli": "^5.2.6",
    "@ngtools/webpack": "^1.10.1",
    "babel-traverse": "6.4.5",
    "babel-types": "6.4.5",
    "babylon": "6.4.5",
    "copy-webpack-plugin": "~4.3.0",
    "css-loader": "^0.28.10",
    "extract-text-webpack-plugin": "~3.0.2",
    "lazy": "1.0.11",
    "nativescript-dev-sass": "^1.4.0",
    "nativescript-dev-typescript": "^0.6.0",
    "nativescript-dev-webpack": "^0.9.2",
    "nativescript-worker-loader": "~0.8.1",
    "raw-loader": "~0.5.1",
    "resolve-url-loader": "~2.2.1",
    "sass-loader": "^6.0.7",
    "typescript": "^2.7.2",
    "uglifyjs-webpack-plugin": "^1.2.3",
    "webpack": "~3.10.0",
    "webpack-bundle-analyzer": "^2.11.0",
    "webpack-sources": "~1.1.0"
  }
PeterStaev commented 6 years ago

Hey @wendt88 , can you provide a reproducible example via https://play.nativescript.org or by attaching the app here. I cannot simulate this error in the demo-ng app in this repo.

mcler commented 6 years ago

Having the same issue on my app. Also could not reproduce it on my own.

Log via Firebase Crash Reports:

Exception com.tns.NativeScriptException: Calling js method onStart failed TypeError: Cannot read property 'getAdapter' of undefined
file: "file:///data/data/<appid>/files/app/bundle.js, line: 1, column: 1027775 StackTrace: Frame: function:'DropDown.refresh',
file:'file:///data/data/<appid>/files/app/bundle.js', line: 1, column: 1027776 Frame: function:'resetChildrenRefreshes',
file:'file:///data/data/<appid>/files/app/bundle.js', line: 1, column: 168710 Frame: function:'localCallback',
file:'<embedded>', line: 36, column: 1117165 Frame: function:'LayoutBaseCommon.eachChildView',
file:'<embedded>', line: 36, column: 1258930 Frame: function:'ViewCommon.eachChild',
file:'<embedded>', line: 36, column: 1344106 Frame: function:'localCallback',
file:'<embedded>', line: 36, column: 1117209 Frame: function:'LayoutBaseCommon.eachChildView',
file:'<embedded>', line: 36, column: 1258930 Frame: function:'ViewCommon.eachChild',
file:'<embedded>', line: 36, column: 1344106 Frame: function:'localCallback',
file:'<embedded>', line: 36, column: 1117209 Frame: function:'LayoutBaseCommon.eachChildView',
file:'<embedded>', line: 36, column: 1258930 Frame: function:'ViewCommon.eachChild',
file:'<embedded>', line: 36, column: 1344106 Frame: function:'localCallback',
file:'<embedded>', line: 36, column: 1117209 Frame: function:'LayoutBaseCommon.eachChildView',
file:'<embedded>', line: 36, column: 1258930 Frame: function:'ViewCommon.eachChild',
file:'<embedded>', line: 36, column: 1344106 Frame: function:'localCallback',
file:'<embedded>', line: 36, column: 1117209 Frame: function:'LayoutBaseCommon.eachChildView',
file:'<embedded>', line: 36, column: 1258930 Frame: function:'ViewCommon.eachChild',
file:'<embedded>', line: 36, column: 1344106 Frame: function:'localCallback',
file:'<embedded>', line: 36, column: 1117209 Frame: function:'LayoutBaseCommon.eachChildView',
file:'<embedded>', line: 36, column: 1258930 Frame: function:'ViewCommon.eachChild',
file:'<embedded>', line: 36, column: 1344106 Frame: function:'localCallback',
file:'<embedded>', line: 36, column: 1117209 Frame: function:'RadSideDrawer.eachChildView',
file:'file:///data/data/<appid>/files/app/bundle.js', line: 1, column: 942358 Frame: function:'ViewCommon.eachChild',
file:'<embedded>', line: 36, column: 1344106 Frame: function:'localCallback',
file:'<embedded>', line: 36, column: 1117209 Frame: function:'LayoutBaseCommon.eachChildView',
file:'<embedded>', line: 36, column: 1258930 Frame: function:'ViewCommon.eachChild',
file:'<embedded>', line: 36, column: 1344106 Frame: function:'localCallback',
file:'<embedded>', line: 36, column: 1117209 Frame: function:'ContentView.eachChildView',
file:'<embedded>', line: 36, column: 774646 Frame: function:'PageBase.eachChildView',
file:'<embedded>', line: 36, column: 1204659 Frame: function:'ViewCommon.eachChild',
file:'<embedded>', line: 36, column: 1344106 Frame: function:'eachDescendant',
file:'<embedded>', line: 36, column: 1117265 Frame: function:'applyOrientationToPage',
file:'file:///data/data/<appid>/files/app/bundle.js', line: 1, column: 169789 Frame: function:'handleNavigatingTo',
file:'file:///data/data/<appid>/files/app/bundle.js', line: 1, column: 170255 Frame: function:'runEvent',
file:'file:///data/data/<appid>/files/app/bundle.js', line: 1, column: 388474 Frame: function:'',
file:'file:///data/data/<appid>/files/app/bundle.js', line: 1, column: 389125 Frame: function:'FrameBase._onNavigatingTo',
file:'<embedded>', line: 36, column: 1195449 Frame: function:'FrameBase.performNavigation',
file:'<embedded>', line: 36, column: 1194377 Frame: function:'FrameBase._processNextNavigationEntry',
file:'<embedded>', line: 36, column: 1194195 Frame: function:'Frame._processNextNavigationEntry',
file:'<embedded>', line: 36, column: 527172 Frame: function:'FrameBase.onLoaded',
file:'<embedded>', line: 36, column: 1189863 Frame: function:'ActivityCallbacksImplementation.onStart',
file:'<embedded>', line: 36, column: 542691 Frame: function:'NativeScriptActivity.onStart',
file:'<embedded>', line: 36, column: 1507125

package.json:


  "dependencies": {
    "@angular/animations": "5.2.*",
    "@angular/common": "5.2.*",
    "@angular/compiler": "5.2.*",
    "@angular/core": "5.2.*",
    "@angular/forms": "5.2.*",
    "@angular/http": "5.2.*",
    "@angular/platform-browser": "5.2.*",
    "@angular/platform-browser-dynamic": "5.2.*",
    "@angular/router": "5.2.*",
    "autolinker": "^1.4.0",
    "dateformat": "^3.0.0",
    "himalaya": "^1.0.0",
    "lodash": "^4.17.4",
    "nativescript-angular": "5.2.*",
    "nativescript-blur": "^2.0.0",
    "nativescript-clipboard": "1.1.*",
    "nativescript-disable-bitcode": "^1.0.0",
    "nativescript-drop-down": "3.2.*",
    "nativescript-effects": "~1.0.0",
    "nativescript-feedback": "^1.1.0",
    "nativescript-loading-indicator": "2.4.*",
    "nativescript-numeric-keyboard": "3.0.*",
    "nativescript-orientation": "^2.1.0",
    "nativescript-platform": "^1.2.2",
    "nativescript-platform-css": "^1.6.5",
    "nativescript-plugin-firebase": "5.1.*",
    "nativescript-pulltorefresh": "2.1.*",
    "nativescript-ui-sidedrawer": "3.5.*",
    "nativescript-webview-interface": "^1.4.2",
    "reflect-metadata": "~0.1.8",
    "rxjs": "~5.5.0",
    "tns-core-modules": "3.4.*",
    "zone.js": "~0.8.2"
  },
  "devDependencies": {
    "@angular/compiler-cli": "5.2.*",
    "@ngtools/webpack": "~1.9.0",
    "@types/autolinker": "^0.24.28",
    "@types/lodash": "4.14.*",
    "ajv": "^6.1.1",
    "babel-traverse": "6.26.*",
    "babel-types": "6.26.*",
    "babylon": "6.18.*",
    "btoa": "^1.1.2",
    "copy-webpack-plugin": "~4.3.1",
    "css-loader": "~0.28.7",
    "extract-text-webpack-plugin": "~3.0.0",
    "filewalker": "0.1.*",
    "fs-extra": "^5.0.0",
    "gm": "^1.23.0",
    "lazy": "1.0.11",
    "md5": "^2.2.1",
    "multi-stage-sourcemap": "^0.2.1",
    "multimatch": "^2.1.0",
    "nativescript-css-loader": "~0.26.0",
    "nativescript-custom-entitlements": "^0.2.0",
    "nativescript-dev-sass": "1.4.*",
    "nativescript-dev-typescript": "~0.6.0",
    "nativescript-dev-webpack": "^0.9.0",
    "nativescript-worker-loader": "~0.8.1",
    "node-sass": "4.7.*",
    "raw-loader": "~0.5.1",
    "resolve-url-loader": "~2.2.0",
    "sass-loader": "^6.0.6",
    "shelljs": "^0.8.0",
    "tns-platform-declarations": "3.4.*",
    "tslint": "^5.8.0",
    "typescript": "~2.6.2",
    "uglifyjs-webpack-plugin": "^1.1.6",
    "webpack": "~3.11.0",
    "webpack-bundle-analyzer": "^2.8.2",
    "webpack-sources": "^1.1.0"
  }
mspusta78 commented 6 years ago

I am having same issue on regular {N} project TypeError: Cannot read property 'getAdapter' of undefined JS: TypeError: Cannot read property 'getAdapter' of undefined

dali-gharbi commented 6 years ago

i have the same issue

JS: ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'getAdapter' of undefined
JS: TypeError: Cannot read property 'getAdapter' of undefined
JS:     at DropDown.refresh (file:///data/data/com.perfony.orbit/files/app/tns_modules/nativescript-drop-down/drop-down.js:75:21)
JS:     at Object.handler [as callback] (file:///data/data/com.perfony.orbit/files/app/tns_modules/tns-core-modules/ui/core/weak-event-listener/weak-event-listener.js:30:34)
Mflm commented 6 years ago

Hi all

I have the same error, the first time it works fine, but when I return the error appears.

But I have the solution.

In the file node_modules\nativescript-drop-down\drop-down.android.js And in the line 73, you can see the function refresh: **this.android.getAdapter().notifyDataSetChanged();**

If you commented this line, the error disappears, but we do not want to change the operation of the plugin.

So the solution is, in the function pageLoaded or your first function, you need to reset the items of the array. viewModel.set("items", items);

I hope it works