Following the Capacitor getting started guide. When adding Sentry to my Ionic+Capacitor+Angular app for the first time, I get this error on compile:
android\app\src\main\java\com\securecoop\app\MainActivity.java:5: error: package io.sentry.capacitor does not exist
import io.sentry.capacitor.SentryCapacitor;
Sentry works fine when running in a browser with live preview. Haven’t tried iOS yet.
Here is my MainActivity.java:
package com.securecoop.app;
import android.os.Bundle;
import com.getcapacitor.BridgeActivity;
import com.getcapacitor.Plugin;
import io.sentry.capacitor.SentryCapacitor;
import java.util.ArrayList;
public class MainActivity extends BridgeActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Initializes the Bridge
this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{
add(SentryCapacitor.class);
}});
}
}
app.module.ts:
(...)
import * as Sentry from '@sentry/capacitor';
import * as SentryAngular from '@sentry/angular';
import { Integrations as TracingIntegrations } from '@sentry/tracing';
Sentry.init(
{
dsn: 'https://XXXXXXXXXXXXXXX@XXXXXXXXXXXXXXX.ingest.sentry.io/XXXXXXXXXXXXXXX',
release: 'securecoop@1.0.0',
dist: '1',
tracesSampleRate: 1.0,
integrations: [
new TracingIntegrations.BrowserTracing({
tracingOrigins: ['localhost', 'https://SecureCoop.com/api'],
}),
],
},
SentryAngular.init
);
@NgModule({
(...)
providers: [
(...)
{
provide: ErrorHandler,
// Attach the Sentry ErrorHandler
useValue: SentryAngular.createErrorHandler(),
},
$ npm list | grep sentry
+-- @sentry/angular@6.16.1
| +-- @sentry/browser@6.16.1
| | +-- @sentry/core@6.16.1
| | | +-- @sentry/hub@6.16.1
| | | | +-- @sentry/types@6.16.1 deduped
| | | | +-- @sentry/utils@6.16.1 deduped
| | | +-- @sentry/minimal@6.16.1
| | | | +-- @sentry/hub@6.16.1 deduped
| | | | +-- @sentry/types@6.16.1 deduped
| | | +-- @sentry/types@6.16.1 deduped
| | | +-- @sentry/utils@6.16.1 deduped
| | +-- @sentry/types@6.16.1 deduped
| | +-- @sentry/utils@6.16.1 deduped
| +-- @sentry/types@6.16.1
| +-- @sentry/utils@6.16.1
| | +-- @sentry/types@6.16.1 deduped
+-- @sentry/capacitor@0.4.1
| +-- @sentry/browser@6.11.0
| | +-- @sentry/core@6.11.0 deduped
| | +-- @sentry/types@6.11.0 deduped
| | +-- @sentry/utils@6.11.0 deduped
| +-- @sentry/core@6.11.0
| | +-- @sentry/hub@6.11.0 deduped
| | +-- @sentry/minimal@6.11.0
| | | +-- @sentry/hub@6.11.0 deduped
| | | +-- @sentry/types@6.11.0 deduped
| | +-- @sentry/types@6.11.0 deduped
| | +-- @sentry/utils@6.11.0 deduped
| +-- @sentry/hub@6.11.0
| | +-- @sentry/types@6.11.0 deduped
| | +-- @sentry/utils@6.11.0 deduped
| +-- @sentry/integrations@6.11.0
| | +-- @sentry/types@6.11.0
| | +-- @sentry/utils@6.11.0
| | | +-- @sentry/types@6.11.0 deduped
| +-- @sentry/tracing@6.11.0
| | +-- @sentry/hub@6.11.0
| | | +-- @sentry/types@6.11.0 deduped
| | | +-- @sentry/utils@6.11.0 deduped
| | +-- @sentry/minimal@6.11.0
| | | +-- @sentry/hub@6.11.0 deduped
| | | +-- @sentry/types@6.11.0 deduped
| | +-- @sentry/types@6.11.0
| | +-- @sentry/utils@6.11.0
| | | +-- @sentry/types@6.11.0 deduped
| +-- @sentry/types@6.11.0
| +-- @sentry/utils@6.11.0
| | +-- @sentry/types@6.11.0 deduped
| +-- @sentry/wizard@1.2.17
| | +-- @sentry/cli@1.71.0