IONIC - cordova-plugin-advanced-http post调用失败,出现Cookie错误

a5g8bdjr  于 2023-06-20  发布在  Ionic
关注(0)|答案(1)|浏览(147)

当从android sdk 32进行post调用时,得到以下错误:-
{"headers":{"normalizedNames":{},"lazyUpdate":null,"headers":{}},"status":-1,"statusText":"Unknown Error","url":"https://ddomain.com/loginUsingApim","ok":false,"name":"HttpErrorResponse","message":"Http failure response for https://ddomain.com/loginUsingApim: -1 undefined","error":"Attempt to invoke virtual method 'java.lang.Class java.lang.Object.getClass()' on a null object reference"}
在日志中我看到了错误:-

An unexpected error occured  
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Class 
java.lang.Object.getClass()' on a null object reference
at cy0.<init>(chromium-TrichromeWebViewGoogle.aab-stable-556311633:4)
at com.android.webview.chromium.a.setCookie(chromium-TrichromeWebViewGoogle.aab-stable-556311633:4)
at com.getcapacitor.plugin.CapacitorCookieManager.setCookie(CapacitorCookieManager.java:123)
at com.getcapacitor.plugin.CapacitorCookieManager.put(CapacitorCookieManager.java:176)
at com.android.okhttp.internal.http.HttpEngine.receiveHeaders(HttpEngine.java:891)at com.android.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:625)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:475) 
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:411)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:542)
at 
com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getResponseCode(DelegatingHttpsURLConnection.java:106)
at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:30)
at com.silkimen.http.HttpRequest.code(HttpRequest.java:1447)
at com.silkimen.http.HttpRequest.stream(HttpRequest.java:1740)
at com.silkimen.http.HttpRequest.buffer(HttpRequest.java:1729)
at com.silkimen.http.HttpRequest.receive(HttpRequest.java:1856)               
at com.silkimen.cordovahttp.CordovaHttpBase.processResponse(CordovaHttpBase.java:195) 
at com.silkimen.cordovahttp.CordovaHttpBase.run(CordovaHttpBase.java:81)  
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:463)   
at java.util.concurrent.FutureTask.run(FutureTask.java:264) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
at java.lang.Thread.run(Thread.java:1012)

我的Package.json文件包含:-

"@angular/common": "^14.2.12",
        "@angular/core": "^14.2.12",
        "@angular/forms": "^14.2.12",
        "@angular/platform-browser": "^14.2.12",
        "@angular/platform-browser-dynamic": "^14.2.12",
        "@angular/router": "^14.2.12",
        "@awesome-cordova-plugins/core": "^5.40.0",
        "@awesome-cordova-plugins/email-composer": "^5.40.0",
        "@awesome-cordova-plugins/screen-orientation": "^5.41.0",
        "@awesome-cordova-plugins/social-sharing": "^5.40.0",
        "@capacitor/android": "4.7.3",
        "@capacitor/app": "^4.0.0",
        "@capacitor/core": "^4.0.0",
        "@capacitor/haptics": "^4.0.0",
        "@capacitor/ios": "^4.0.0",
        "@capacitor/keyboard": "^4.0.0",
        "@capacitor/preferences": "^4.0.0",
        "@ionic-native/app-availability": "^5.31.0",
        "@ionic-native/app-version": "^5.36.0",
        "@ionic-native/core": "^5.33.1",
        "@ionic-native/file": "^5.31.1",
        "@ionic-native/http": "^5.34.0",
        "@ionic-native/in-app-browser": "^5.36.0",
        "@ionic-native/ionic-webview": "^5.36.0",
        "@ionic-native/local-notifications": "^5.36.0",
        "@ionic-native/network": "^5.33.1",
        "@ionic-native/pdf-generator": "^5.34.0",
        "@ionic-native/social-sharing": "^5.36.0",
        "@ionic-native/sqlite": "^5.33.1",
        "@ionic-native/sqlite-porter": "^5.33.1",
        "@ionic-native/web-intent": "^5.36.0",
        "@ionic-native/zip": "^5.36.0",
        "@ionic/angular": "^6.3.8",
        "@ionic/storage": "^3.0.6",
        "@ionic/storage-angular": "^3.0.6",
        "@obsidize/rotating-file-stream": "1.1.0",
        "@obsidize/rx-console": "2.0.2",
        "@types/crypto-js": "^4.1.1",
        "@types/hammerjs": "^2.0.41",
        "chart.js": "^3.7.0",
        "com-darryncampbell-cordova-plugin-intent": "^2.2.0",
        "cordova-plugin-advanced-http": "3.2.0",
        "cordova-plugin-androidx": "^3.0.0",
        "cordova-plugin-androidx-adapter": "^1.1.3",
        "cordova-plugin-appavailability": "^0.4.2",
        "cordova-plugin-email-composer": "^0.10.0",
        "cordova-plugin-file": "^6.0.2",
        "cordova-plugin-fullscreen": "^1.3.0",
        "cordova-plugin-inappbrowser": "^5.0.0",
        "cordova-plugin-market": "^1.2.0",
        "cordova-plugin-network-information": "^3.0.0",
        "cordova-plugin-screen-orientation": "^3.0.2",
        "cordova-plugin-x-socialsharing": "^6.0.3",
        "cordova-zip-plugin": "^2.0.0",
        "crypto-js": "^4.1.1",
        "d3": "7.0.1",
        "es6-promise-plugin": "^4.2.2",
        "file-saver": "^2.0.5",
        "hammerjs": "^2.0.8",
        "handlebars": "^4.7.7",
        "intent-plugin": "^0.0.1",
        "ionic-pullup": "6.1.0-beta.1",
        "js-htmlencode": "^0.3.0",
        "jszip": "^3.9.1",
        "moment": "^2.29.1",
        "ng-circle-progress": "^1.6.0",
        "rxjs": "~6.6.0",
        "tslib": "~2.0.0",
        "xlsx": "^0.18.5",
        "zone.js": "~0.11.4"
      },
      "devDependencies": {
        "@angular-devkit/build-angular": "^14.2.10",
        "@angular-eslint/builder": "^14.2.0",
        "@angular-eslint/eslint-plugin": "^14.2.0",
        "@angular-eslint/eslint-plugin-template": "^14.2.0",
        "@angular-eslint/template-parser": "^14.2.0",
        "@angular/cli": "^14.2.10",
        "@angular/compiler": "^14.2.12",
        "@angular/compiler-cli": "^14.2.12",
        "@angular/language-service": "^14.2.12",
        "@capacitor/cli": "^4.0.0",
        "@ionic-native/app-version": "^5.36.0",
        "@ionic/angular-toolkit": "^7.0.0",
        "@types/jasmine": "~3.6.0",
        "@types/jasminewd2": "~2.0.3",
        "@types/jquery": "^3.5.6",
        "@types/node": "^12.20.47",
        "@typescript-eslint/eslint-plugin": "4.16.1",
        "@typescript-eslint/parser": "4.16.1",
        "cordova-pdf-generator": "^2.1.1",
        "cordova-sqlite-storage": "^6.0.0",
        "cordova.plugins.diagnostic": "^6.0.3",
        "eslint": "^7.6.0",
        "eslint-plugin-import": "2.22.1",
        "eslint-plugin-jsdoc": "30.7.6",
        "eslint-plugin-prefer-arrow": "1.2.2",
        "jasmine-core": "4.5.0",
        "jasmine-spec-reporter": "7.0.0",
        "karma": "~6.4.1",
        "karma-chrome-launcher": "~3.1.1",
        "karma-coverage": "~2.2.0",
        "karma-coverage-istanbul-reporter": "~3.0.3",
        "karma-jasmine": "~5.1.0",
        "karma-jasmine-html-reporter": "^2.0.0",
        "protractor": "~7.0.0",
        "ts-node": "~8.3.0",
        "typescript": "~4.6.4",
        "uk.co.workingedge.cordova.plugin.sqliteporter": "^1.1.1"
      }
    }

有人遇到过同样的问题吗?它似乎工作正常,当我在CapacitorCookieManager.json中注解出下面的代码时,位置node_modules@capacitor\android\capacitor\src\main\java\com\getcapacitor\plugin

public void setCookie(String url, String value) {
    //webkitCookieManager.setCookie(url, value);
    //flush();
}
5gfr0r5j

5gfr0r5j1#

我相信这个问题在Capacitor v5中已经解决了。issue history是可用的,它在更新日志中被引用。

相关问题