【问题标题】:Calling js method onCreateView failed System.err: TypeError: Right-hand side of 'instanceof' is not an object Nativescript调用 js 方法 onCreateView 失败 System.err: TypeError: 'instanceof' 的右侧不是对象 Nativescript
【发布时间】:2020-05-06 11:38:20
【问题描述】:

我正在尝试在我的 Nativescript 应用程序中使用 AppSync。这是我关注的链接

https://market.nativescript.org/plugins/nativescript-app-sync

按照上面的链接,我有一个代码可以检查应用程序是否是最新的

每当我添加此代码时

AppSync.sync({
    deploymentKey: isIOS ? "my-ios-deployment-key" : "my-android-deployment-key",
    installMode: InstallMode.ON_NEXT_RESUME, // this is the default install mode; the app updates upon the next cold boot (unless the --mandatory flag was specified while pushing the update)
    mandatoryInstallMode: isIOS ? InstallMode.ON_NEXT_RESUME : InstallMode.IMMEDIATE, // the default is InstallMode.ON_NEXT_RESUME which doesn't bother the user as long as the app is in the foreground. InstallMode.IMMEDIATE shows an installation prompt. Don't use that for iOS AppStore distributions because Apple doesn't want you to, but if you have an Enterprise-distributed app, go right ahead!
    updateDialog: { // only used for InstallMode.IMMEDIATE
        updateTitle: "Please restart the app", // an optional title shown in the update dialog
        optionalUpdateMessage: "Optional update msg",   // a message shown for non-"--mandatory" releases
        mandatoryUpdateMessage: "Mandatory update msg", // a message shown for "--mandatory" releases
        optionalIgnoreButtonLabel: "Later", // if a user wants to continue their session, the update will be installed on next resume
        mandatoryContinueButtonLabel: isIOS ? "Exit now" : "Restart now", // On Android we can kill and restart the app, but on iOS that's not possible so the user has to manually restart it. That's why we provide a different label in this example.
        appendReleaseDescription: true // appends the description you (optionally) provided when releasing a new version to AppSync
    } });

我总是看到这个错误

System.err: An uncaught Exception occurred on "main" thread.
System.err: Calling js method onCreateView failed
System.err: TypeError: Right-hand side of 'instanceof' is not an object
System.err:
System.err: StackTrace:
System.err: (file: node_modules\@nativescript\core\ui\layouts\flexbox-layout\flexbox-layout.android.js:14:14)
System.err:     at applyAllNativeSetters(file: node_modules\@nativescript\core\ui\core\properties\properties.js:1065:37)
System.err:     at initNativeView(file: node_modules\@nativescript\core\ui\core\properties\properties.js:992:8)
System.err:     at ViewBase.onResumeNativeUpdates(file: node_modules\@nativescript\core\ui\core\view-base\view-base.js:647:21)
System.err:     at ViewBase._resumeNativeUpdates(file: node_modules\@nativescript\core\ui\core\view-base\view-base.js:278:17)
System.err:     at ViewBase.onLoaded(file: node_modules\@nativescript\core\ui\core\view-base\view-base.js:232:13)
System.err:     at View.onLoaded(file: node_modules\@nativescript\core\ui\core\view\view.android.js:249:34)
System.err:     at (file: node_modules\@nativescript\core\ui\core\view-base\view-base.js:317:89)
System.err:     at ViewBase.callFunctionWithSuper(file: node_modules\@nativescript\core\ui\core\view-base\view-base.js:310:8)
System.err:     at ViewBase.callLoaded(file: node_modules\@nativescript\core\ui\core\view-base\view-base.js:317:13)
System.err:     at ViewBase.loadView(file: node_modules\@nativescript\core\ui\core\view-base\view-base.js:456:17)
System.err:     at (file: node_modules\@nativescript\core\ui\core\view-base\view-base.js:234:18)
System.err:     at ContentView.eachChildView(file: node_modules\@nativescript\core\ui\content-view\content-view.js:70:12)
System.err:     at PageBase.eachChildView(file: node_modules\@nativescript\core\ui\page\page-common.js:126:39)
System.err:     at ViewCommon.eachChild(file: node_modules\@nativescript\core\ui\core\view\view-common.js:925:13)
System.err:     at ViewBase.onLoaded(file: node_modules\@nativescript\core\ui\core\view-base\view-base.js:233:13)
System.err:     at View.onLoaded(file: node_modules\@nativescript\core\ui\core\view\view.android.js:249:34)
System.err:     at Page.onLoaded(file: node_modules\@nativescript\core\ui\page\page.android.js:43:34)
System.err:     at (file: node_modules\@nativescript\core\ui\core\view-base\view-base.js:317:89)
System.err:     at ViewBase.callFunctionWithSuper(file: node_modules\@nativescript\core\ui\core\view-base\view-base.js:310:8)
System.err:     at ViewBase.callLoaded(file: node_modules\@nativescript\core\ui\core\view-base\view-base.js:317:13)
System.err:     at ViewBase.loadView(file: node_modules\@nativescript\core\ui\core\view-base\view-base.js:456:17)
System.err:     at ViewBase._addViewCore(file: node_modules\@nativescript\core\ui\core\view-base\view-base.js:451:17)
System.err:     at ViewBase._addView(file: node_modules\@nativescript\core\ui\core\view-base\view-base.js:437:13)
System.err:     at FragmentCallbacksImplementation.onCreateView(file: node_modules\@nativescript\core\ui\frame\frame.android.js:700:18)
System.err:     at FragmentClass.onCreateView(file: node_modules\@nativescript\core\ui\frame\fragment.android.js:29:37)
System.err:     at com.tns.Runtime.callJSMethodNative(Native Method)
System.err:     at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1286)
System.err:     at com.tns.Runtime.callJSMethodImpl(Runtime.java:1173)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:1160)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:1138)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:1134)
System.err:     at com.tns.FragmentClass.onCreateView(FragmentClass.java:53)
System.err:     at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2439)
System.err:     at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManager.java:1460)
System.err:     at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1784)
System.err:     at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManager.java:1852)
System.err:     at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:802)
System.err:     at androidx.fragment.app.FragmentManagerImpl.executeOps(FragmentManager.java:2625)
System.err:     at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2411)
System.err:     at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2366)
System.err:     at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2273)
System.err:     at androidx.fragment.app.FragmentManagerImpl$1.run(FragmentManager.java:733)
System.err:     at android.os.Handler.handleCallback(Handler.java:751)
System.err:     at android.os.Handler.dispatchMessage(Handler.java:95)
System.err:     at android.os.Looper.loop(Looper.java:154)
System.err:     at android.app.ActivityThread.main(ActivityThread.java:6119)
System.err:     at java.lang.reflect.Method.invoke(Native Method)
System.err:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

但是,只要注释掉上面的行,应用程序就会运行得很好

我在这里错过了什么

请帮帮我

我的 package.json 看起来像这样

"tns-ios": {
      "version": "6.5.0"
    },
    "tns-android": {
      "version": "6.5.0"
    }
  },
  "dependencies": {
    "@nativescript/theme": "~2.3.3",
    "nativescript-vue": "~2.5.0",
    "nativescript-webrtc-plugin": "^2.0.0-alpha.19",
    "nativescript-app-sync": "^2.0.0",
    "tns-core-modules": "~6.5.0",
    "@nstudio/nativescript-pulltorefresh": "^1.1.1",
    "axios": "^0.19.2",
    "country-code-info": "^0.3.0",
    "firebase": "^7.14.2",
    "firebase-admin": "^8.11.0",
    "libphonenumber-js": "^1.7.51",
    "mathjs": "^6.6.5",
    "nativescript-activity-detection": "^0.1.1",
    "nativescript-contacts-lite": "^0.2.6",
    "nativescript-exit": "^1.0.1",
    "nativescript-geolocation": "^5.1.0",
    "nativescript-headset-detection": "^1.0.0",
    "nativescript-local-notifications": "^4.2.1",
    "nativescript-permissions": "^1.3.9",
    "nativescript-plugin-firebase": "^10.5.2",
    "nativescript-social-share": "^1.6.0",
    "nativescript-socketio": "^3.3.1",
    "nativescript-toast": "^2.0.0",
    "vuex": "^3.3.0"
  },
  "devDependencies": {
    "@babel/core": "~7.1.0",
    "@babel/preset-env": "~7.1.0",
    "babel-loader": "~8.0.0",
    "nativescript-dev-webpack": "~1.5.1",
    "nativescript-vue-template-compiler": "~2.5.0",
    "node-sass": "^4.7.1",
    "@types/node": "^13.13.4",
    "dotenv": "^8.2.0",
    "nativescript-worker-loader": "^0.11.0",
    "tns-platform-declarations": "^6.5.1",
    "typescript": "^3.8.3",
    "vue": "^2.6.11",
    "vue-loader": "^15.9.2"
  },
  "prettier": {
    "trailingComma": "es5",
    "tabWidth": 2,
    "semi": false,
    "singleQuote": true,
    "bracketSpacing": true,
    "arrowParens": "avoid",
    "printWidth": 120
  }

【问题讨论】:

  • 您将应用同步代码放在哪里?
  • 我已将此代码放在 main.ts 中

标签: android vue.js nativescript


【解决方案1】:

转到@nativescript/core/ui/layouts/flexbox-layout/flexbox-layout.android.js

替换:

var widgetFlexboxLayout;
var widgetLayoutParams;

let widgetFlexboxLayout= org.nativescript.widgets.FlexboxLayout;
let widgetLayoutParams= org.nativescript.widgets.FlexboxLayout.LayoutParams;

【讨论】:

    猜你喜欢
    • 2023-02-14
    • 2018-11-11
    • 2019-09-17
    • 2023-01-31
    • 1970-01-01
    • 1970-01-01
    • 2017-09-16
    • 2017-01-18
    • 2019-11-16
    相关资源
    最近更新 更多