Answer the question
In order to leave comments, you need to log in
We use the Ionic + Capacitor platform. Why does the application crash when connecting the https://appmetrica.yandex.ru metric?
Hello. We use the Ionic + Capacitor platform. When connecting https://appmetrica.yandex.ru metrics, the application crashes
In the console
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.lk2.app, PID: 21570
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.lk2.app/com.lk2.app.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void org.apache.cordova.CordovaPlugin.privateInitialize(java.lang.String, org.apache.cordova.CordovaInterface, org.apache.cordova.CordovaWebView, org.apache.cordova.CordovaPreferences)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void org.apache.cordova.CordovaPlugin.privateInitialize(java.lang.String, org.apache.cordova.CordovaInterface, org.apache.cordova.CordovaWebView, org.apache.cordova.CordovaPreferences)' on a null object reference
at org.apache.cordova.PluginManager.getPlugin(PluginManager.java:171)
at org.apache.cordova.PluginManager.startupPlugins(PluginManager.java:97)
at org.apache.cordova.PluginManager.init(PluginManager.java:86)
at com.getcapacitor.cordova.MockCordovaWebViewImpl.init(MockCordovaWebViewImpl.java:62)
at com.getcapacitor.BridgeActivity.load(BridgeActivity.java:79)
at com.getcapacitor.BridgeActivity.init(BridgeActivity.java:62)
at com.getcapacitor.BridgeActivity.init(BridgeActivity.java:48)
at com.lk2.app.MainActivity.onCreate(MainActivity.java:18)
at android.app.Activity.performCreate(Activity.java:7136)
at android.app.Activity.performCreate(Activity.java:7127)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
I/Process: Sending signal. PID: 21570 SIG: 9
implementation 'com.android.installreferrer:installreferrer:2.1'
"dependencies": {
"@angular/animations": "~8.2.14",
"@angular/cdk": "~8.2.3",
"@angular/common": "~8.2.14",
"@angular/core": "~8.2.14",
"@angular/forms": "~8.2.14",
"@angular/material": "^8.2.3",
"@angular/platform-browser": "~8.2.14",
"@angular/platform-browser-dynamic": "~8.2.14",
"@angular/router": "~8.2.14",
"@angular/service-worker": "~8.2.14",
"@capacitor/android": "^2.3.0",
"@capacitor/core": "^2.3.0",
"@capacitor/ios": "^2.3.0",
"@ionic-native/android-permissions": "^5.26.0",
"@ionic-native/camera": "^5.26.0",
"@ionic-native/core": "^5.22.0",
"@ionic-native/file": "^5.26.0",
"@ionic-native/file-chooser": "^5.27.0",
"@ionic-native/file-opener": "^5.26.0",
"@ionic-native/file-path": "^5.27.0",
"@ionic-native/geolocation": "^5.22.0",
"@ionic-native/http": "^5.25.0",
"@ionic-native/location-accuracy": "^5.26.0",
"@ionic-native/splash-screen": "^5.22.0",
"@ionic-native/status-bar": "^5.22.0",
"@ionic/angular": "^5.0.4",
"@ionic/pwa-elements": "^1.5.1",
"@ionic/storage": "^2.2.0",
"@ngx-formly/core": "^5.0.0",
"@ngx-formly/ionic": "^5.0.0",
"@ngx-formly/schematics": "^5.5.15",
"cordova-plugin-advanced-http": "^2.4.1",
"cordova-plugin-android-permissions": "^1.0.2",
"cordova-plugin-camera": "^4.1.0",
"cordova-plugin-file": "^6.0.2",
"cordova-plugin-file-opener2": "^3.0.2",
"cordova-plugin-filechooser": "^1.2.0",
"cordova-plugin-filepath": "^1.5.8",
"cordova-plugin-geolocation": "^4.0.2",
"cordova-plugin-request-location-accuracy": "^2.3.0",
"cordova-plugin-splashscreen": "^5.0.3",
"cordova-plugin-statusbar": "^2.4.3",
"cordova-sqlite-storage": "^5.0.0",
"core-js": "^2.5.4",
"file-saver": "^2.0.2",
"hammerjs": "^2.0.8",
"http-server": "^0.12.3",
"ionic-input-mask": "^1.0.1",
"jetifier": "^1.6.6",
"lodash": "^4.17.15",
"moment": "^2.24.0",
"ngx-connection-service": "^7.0.3",
"ngx-mask": "^8.1.7",
"ngx-mask-ionic": "^1.1.2",
"ngx-perfect-scrollbar": "^9.0.0",
"rxjs": "~6.5.1",
"text-mask-core": "^5.1.2",
"tslib": "^1.11.1",
"uuid4": "^1.1.4",
"yandex-appmetrica-plugin-cordova": "^1.0.0",
"yandex-locator": "0.0.8",
"zone.js": "~0.9.1"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.803.25",
"@angular/cli": "~8.3.23",
"@angular/compiler": "~8.2.14",
"@angular/compiler-cli": "~8.2.14",
"@angular/language-service": "~8.2.14",
"@capacitor/cli": "^2.3.0",
"@ionic/angular-toolkit": "^2.2.0",
"@types/file-saver": "^2.0.1",
"@types/jasmine": "~3.3.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"codelyzer": "^5.0.0",
"jasmine-core": "~3.4.0",
"jasmine-spec-reporter": "~4.2.1",
"jest": "^26.1.0",
"karma": "^4.4.1",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.0",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.15.0",
"typescript": "~3.4.3"
},
this.platform.ready().then(async () => {
this._yandexMetricaService.onDeviceReady();
.....
`onDeviceReady() {
// @ts-ignore
window.appMetrica.activate(yandexConfig.yandexAppMetrika);
this.forEach(document.getElementsByTagName('button'), function (button) {
// Workaround for buttons click animation.
button.addEventListener("touchstart", function () { return true; });
button.addEventListener("click", this.actions[button.id]);
});
this.forEach(document.getElementsByTagName('input'), function (checkbox) {
if (checkbox.getAttribute('type') == 'checkbox') {
checkbox.addEventListener("click", this.actions[checkbox.id]);
}
});
}`
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question