Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android: initManager was called twice #183

Open
schematical opened this issue Feb 16, 2022 · 3 comments
Open

Android: initManager was called twice #183

schematical opened this issue Feb 16, 2022 · 3 comments

Comments

@schematical
Copy link

schematical commented Feb 16, 2022

Error:

2022-02-16 15:37:11.921 25257-25629/com.rocksolidstabilization.dispatch.v2.dev E/PluginManager: Uncaught exception from plugin
    java.lang.IllegalStateException: initManager was called twice
        at com.spoon.backgroundfileupload.FileTransferBackground.initManager(FileTransferBackground.java:158)
        at com.spoon.backgroundfileupload.FileTransferBackground.execute(FileTransferBackground.java:129)
        at org.apache.cordova.CordovaPlugin.execute(CordovaPlugin.java:98)
        at org.apache.cordova.PluginManager.exec(PluginManager.java:146)
        at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:59)
        at org.apache.cordova.engine.SystemExposedJsApi.exec(SystemExposedJsApi.java:41)
        at android.os.MessageQueue.nativePollOnce(Native Method)
        at android.os.MessageQueue.next(MessageQueue.java:386)
        at android.os.Looper.loop(Looper.java:169)
        at android.os.HandlerThread.run(HandlerThread.java:65)

So I added break points inside cordova.js the androidExec function and verified it was NOT getting called twice from the browser.

It looks like the error calling the call back deletes the callback from the cordova adapter queue so I cannot get any information after this error even though looking at logcat the error finshes.

Thoughts?

@zfir
Copy link
Member

zfir commented Feb 17, 2022

Hello @schematical,

Can you please send your codes where you are using this plugin and also your package.json?

Regards,
Zafir

@schematical
Copy link
Author

getBackgroundFileTransferManager() {
    if (!this.backgroundFileTransferManager) {

      this.backgroundFileTransferManager = new window.FileTransferManager.init(
        {
           // callBack: (event) => {   console.log("X: ", event); } 
        },
        this.onBackgroundUploadEvent.bind(this));
    }
    return this.backgroundFileTransferManager;
  }
  queueBackgroundUpload(payload: any) {
        this.getBackgroundFileTransferManager().startUpload(
            payload
          );
      });
  }

And package.json

{
"name": "@xyz/mobile",r
"version": "0.29.0",
"author": "Mobile Aplication",
"homepage": "https://www.xyz.com/",
"scripts": {
  "build": "ng build --configuration=ci",
  "build:android": "ionic cordova build android",
  "build:all": "ng build && npm run build:android && npm run build:ios",
  "build:ios": "ionic cordova build ios",
  "build:ios:prod": "ionic cordova build ios --configuration prod",
  "build:android:prod": "ionic cordova build android --prod",
  "check": "npm run lint && npm run test:cov && npm run build",
  "ng": "ng",
  "start": "ng serve --port 8100",
  "start:devices": "ng build && cordova run android && cordova run ios",
  "start:ios": "ionic cordova run ios",
  "start:ios:live": "ionic cordova run ios -l",
  "start:ios:prod": "ionic cordova run ios -l --address=localhost --prod",
  "start:android": "ionic cordova run android",
  "start:android:live": "ionic cordova run android -l",
  "start:android:prod": "ionic cordova run android -l --address=localhost --prod",
  "test": "jest --watch=false",
  "test:cov": "jest --coverage --watch=false",
  "test:watch": "ng test --watch",
  "test:mutation": "stryker run",
  "lint": "ng lint",
  "e2e": "ng e2e",
  "graphql:codegen": "graphql-codegen --config scripts/codegen.yml"
},
"private": true,
"dependencies": {
  "@angular/animations": "^10.1.0",
  "@angular/cdk": "^10.2.0",
  "@angular/cli": "^10.1.0",
  "@angular/common": "^10.1.0",
  "@angular/core": "^10.1.0",
  "@angular/forms": "^10.1.0",
  "@angular/material": "^10.2.0",
  "@angular/platform-browser": "^10.1.0",
  "@angular/platform-browser-dynamic": "^10.1.0",
  "@angular/router": "^10.1.0",
  "@apollo/client": "^3.3.21",
  "@fortawesome/angular-fontawesome": "^0.6.1",
  "@fortawesome/fontawesome-svg-core": "^1.2.32",
  "@fortawesome/free-regular-svg-icons": "^5.13.0",
  "@fortawesome/free-solid-svg-icons": "^5.13.0",
  "@ionic-native/app-version": "^5.28.0",
  "@ionic-native/background-upload": "^5.36.0",
  "@ionic-native/call-number": "^5.31.1",
  "@ionic-native/camera": "^5.24.0",
  "@ionic-native/core": "^5.20.0",
  "@ionic-native/device": "^5.34.0",
  "@ionic-native/file": "^5.23.0",
  "@ionic-native/in-app-browser": "^5.34.0",
  "@ionic-native/keyboard": "^5.32.0",
  "@ionic-native/launch-navigator": "^5.31.1",
  "@ionic-native/launch-review": "^5.28.0",
  "@ionic-native/network": "^5.20.0",
  "@ionic-native/push": "^5.24.0",
  "@ionic-native/social-sharing": "^5.34.0",
  "@ionic-native/splash-screen": "^5.20.0",
  "@ionic-native/status-bar": "^5.20.0",
  "@ionic/angular": "^5.0.7",
  "@ionic/angular-toolkit": "^2.2.0",
  "@ionic/storage": "^2.3.1",
  "@netflix/nerror": "^1.1.3",
  "amazing-time-picker": "^1.8.0",
  "apollo-angular": "^2.0.4",
  "apollo-angular-link-http": "^1.10.0",
  "apollo-cache-inmemory": "^1.6.0",
  "apollo-client": "^2.6.0",
  "apollo-link": "^1.2.11",
  "apollo-link-context": "^1.0.19",
  "cordova-plugin-camera": "^6.0.0",
  "cordova-plugin-datepicker": "^0.9.3",
  "cordova-plugin-device": "^2.0.3",
  "cordova-plugin-ionic-keyboard": "^2.2.0",
  "cordova-plugin-ionic-webview": "^5.0.0",
  "cordova-plugin-network-information": "^2.0.2",
  "cordova-plugin-splashscreen": "^6.0.0",
  "cordova-plugin-statusbar": "^2.4.3",
  "cordova-res": "^0.15.4",
  "cordova-sqlite-storage": "6.0.0",
  "cordova-support-google-services": "1.4.1",
  "core-js": "^3.6.5",
  "font-awesome": "^4.7.0",
  "gql-query-builder": "^3.5.5",
  "graphql": "^15.3.0",
  "graphql-tag": "^2.10.0",
  "jszip": "^3.6.0",
  "jwt-decode": "^2.2.0",
  "lodash": "^4.17.15",
  "moment": "^2.24.0",
  "moment-timezone": "^0.5.31",
  "read-chunk": "^3.2.0",
  "rxjs": "~6.6.2",
  "signature_pad": "^4.0.0",
  "tslib": "^1.10.0",
  "typeorm": "^0.2.31",
  "uuid": "^8.3.2",
  "webpack-dev-server": "^3.11.0",
  "zone.js": "^0.10.3"
},
"devDependencies": {
  "@angular-devkit/architect": "^0.1000.8",
  "@angular-devkit/build-angular": "^0.1001.0",
  "@angular-devkit/core": "^10.1.0",
  "@angular-devkit/schematics": "^10.1.0",
  "@angular/compiler": "^10.1.0",
  "@angular/compiler-cli": "^10.1.0",
  "@angular/language-service": "^10.1.0",
  "@commitlint/cli": "^8.3.5",
  "@commitlint/config-conventional": "^8.3.4",
  "@graphql-codegen/cli": "^1.13.2",
  "@graphql-codegen/introspection": "^1.13.2",
  "@graphql-codegen/typescript": "^1.13.2",
  "@graphql-codegen/typescript-operations": "^1.13.2",
  "@havesource/cordova-plugin-push": "^3.0.0",
  "@ionic/lab": "3.1.1",
  "@spoonconsulting/cordova-plugin-background-upload": "^2.0.7",
  "@stryker-mutator/api": "^3.3.1",
  "@stryker-mutator/core": "^3.3.1",
  "@stryker-mutator/html-reporter": "^3.1.0",
  "@stryker-mutator/karma-runner": "^3.3.1",
  "@stryker-mutator/typescript": "^3.3.1",
  "@types/jest": "^26.0.13",
  "@types/lodash": "^4.14.150",
  "@types/node": "^13.13.1",
  "call-number": "^1.0.1",
  "codelyzer": "^5.0.0",
  "cordova-android": "^10.1.1",
  "cordova-ios": "^6.1.1",
  "cordova-launch-review": "^4.0.0",
  "cordova-plugin-actionsheet": "^2.3.3",
  "cordova-plugin-androidx": "^1.0.2",
  "cordova-plugin-androidx-adapter": "^1.1.0",
  "cordova-plugin-app-version": "^0.1.9",
  "cordova-plugin-dialogs": "^2.0.2",
  "cordova-plugin-file": "^6.0.2",
  "cordova-plugin-inappbrowser": "^5.0.0",
  "cordova-plugin-whitelist": "^1.3.5",
  "crypto-js": "^4.0.0",
  "husky": "^4.2.5",
  "jasmine-core": "^3.5.0",
  "jasmine-spec-reporter": "~4.2.1",
  "jest": "^26.4.2",
  "jest-preset-angular": "^8.3.1",
  "karma": "^5.0.2",
  "karma-chrome-launcher": "^3.1.0",
  "karma-coverage-istanbul-reporter": "^2.0.6",
  "karma-jasmine": "^3.1.1",
  "karma-jasmine-html-reporter": "^1.5.3",
  "karma-spec-reporter": "0.0.32",
  "lint-staged": "^9.5.0",
  "mx.ferreyra.callnumber": "0.0.2",
  "prettier": "^1.19.1",
  "protractor": "^5.4.3",
  "sqlite3": "^5.0.2",
  "ts-jest": "^26.4.2",
  "ts-node": "~7.0.0",
  "tslint": "~5.15.0",
  "typescript": "~3.9.7",
  "uk.co.workingedge.phonegap.plugin.launchnavigator": "^5.0.6"
},
"browser": {
  "crypto": false
},
"description": "An Ionic project",
"husky": {
  "hooks": {
    "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
  }
},
"lint-staged": {
  "*.ts": [
    "prettier --write",
    "git add",
    "tslint -p tsconfig.json -c tslint.json"
  ]
},
"cordova": {
  "plugins": {
    "cordova-plugin-statusbar": {},
    "cordova-plugin-device": {},
    "cordova-plugin-splashscreen": {},
    "cordova-plugin-ionic-keyboard": {},
    "cordova-plugin-network-information": {},
    "cordova-sqlite-storage": {},
    "cordova-plugin-camera": {
      "ANDROIDX_CORE_VERSION": "1.6.+"
    },
    "cordova-plugin-file": {},
    "cordova-plugin-datepicker": {},
    "cordova-plugin-ionic-webview": {
      "ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+"
    },
    "cordova-plugin-app-version": {},
    "cordova-launch-review": {
      "ANDROID_PLAY_SERVICES_CORE_VERSION": "1.8.0"
    },
    "uk.co.workingedge.phonegap.plugin.launchnavigator": {
      "GOOGLE_API_KEY_FOR_ANDROID": "AIzaSyBVlE6iZnOzhTTGuPa-ZX8BK0at4Mm9kyE",
      "GOOGLE_API_KEY_FOR_IOS": "AIzaSyBVlE6iZnOzhTTGuPa-ZX8BK0at4Mm9kyE",
      "OKHTTP_VERSION": "3.12.0"
    },
    "mx.ferreyra.callnumber": {},
    "call-number": {},
    "cordova-plugin-inappbrowser": {},
    "@havesource/cordova-plugin-push": {
      "ANDROIDX_CORE_VERSION": "1.6.+",
      "FCM_VERSION": "18.+",
      "IOS_FIREBASE_MESSAGING_VERSION": "~> 6.32.2"
    },
    "cordova-plugin-whitelist": {},
    "@spoonconsulting/cordova-plugin-background-upload": {}
  },
  "platforms": [
    "ios",
    "android"
  ]
}
}

@zfir
Copy link
Member

zfir commented Feb 21, 2022

Hello @schematical,

Make sure "@spoonconsulting/cordova-plugin-background-upload": "^2.0.7" is in dependencies and not dev-dependencies.

Also try to use declare var FileTransferManager: any; instead of new window.FileTransferManager.init(...). CHeck the README for more details(Sample usage)

Regards,
Zafir.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants