---
title: "Migrate from sentry-android 1.x to 2.x"
description: "Learn about migrating from Sentry Android SDK 1.x to 2.x."
url: https://docs.sentry.io/platforms/android/migration/v1-to-v2/
---

# Migrate from sentry-android 1.x to 2.x | Sentry for Android

With Sentry Android, we've updated the API to resemble the [Unified API](https://develop.sentry.dev/sdk/miscellaneous/unified-api/) more closely. And now that the SDK isn't built on top of `io.sentry:sentry-java`, Sentry Android has more Android-specific features.

If you want to upgrade from the previous version of the SDK, please check the following sections of changes that may need updating in your code.

## [Configuration](https://docs.sentry.io/platforms/android/migration/v1-to-v2.md#configuration)

The file `sentry.properties` used by the previous version of the SDK has been discontinued. Configurations for the new SDK are in `AndroidManifest.xml` or directly in the code.

Example of the configuration in the Manifest:

```xml
<application>
    <!-- Example of the Sentry DSN setting -->
    <meta-data
    android:name="io.sentry.dsn"
    android:value="___PUBLIC_DSN___"
  />
</application>
```

If you want to set the configuration manually in the code, you need to initialize the SDK with `SentryAndroid.init()` --- described in [Installation](https://docs.sentry.io/platforms/android/migration/v1-to-v2.md#installation) --- in the same file as `SentryAndroidOptions`, which holds configuration items.

## [Installation](https://docs.sentry.io/platforms/android/migration/v1-to-v2.md#installation)

The new SDK can initialize automatically, all you need to do is provide the DSN in your Manifest file, as shown in the previous example in [Configuration](https://docs.sentry.io/platforms/android/migration/v1-to-v2.md#configuration).

### [Manual Installation](https://docs.sentry.io/platforms/android/migration/v1-to-v2.md#manual-installation)

If you want to register any callback to filter and modify events and/or breadcrumbs, or if you want to provide the configuration values via code, you need to initialize the SDK using the `SentryAndroid.init()`.

To initialize the SDK manually:

* Disable the `auto-init` feature by providing the following line in the manifest:

  ```xml
  <application>
      <meta-data android:name="io.sentry.auto-init" android:value="false" />
  </application>
  ```

* Initialize the SDK directly in your application:

```java
SentryAndroid.init(this, options -> {
  options.setDsn("___PUBLIC_DSN___");
});
```

## [Releases](https://docs.sentry.io/platforms/android/migration/v1-to-v2.md#releases)

Please note that the new SDK will send with each event a release version in a different format than the previous SDK.

If you are using the [GitHub](https://docs.sentry.io/organization/integrations/source-code-mgmt/github.md) or [GitLab](https://docs.sentry.io/organization/integrations/source-code-mgmt/gitlab.md) integrations, you need to do one of the following:

* [Use the new format](https://docs.sentry.io/platforms/android/configuration/releases.md)
* Set the release in your `AndroidManifest.xml`
* Change your code as described in the configuration section

## [API](https://docs.sentry.io/platforms/android/migration/v1-to-v2.md#api)

### [Set tag](https://docs.sentry.io/platforms/android/migration/v1-to-v2.md#set-tag)

*Old*:

```java
Sentry.getContext().addTag("tagName", "tagValue");
```

*New*:

```java
Sentry.setTag("tagName", "tagValue");
```

### [Capture custom exception](https://docs.sentry.io/platforms/android/migration/v1-to-v2.md#capture-custom-exception)

*Old*:

```java
try {
  int x = 1 / 0;
} catch (Exception e) {
  Sentry.capture(e);
}
```

*New*:

```java
try {
  int x = 1 / 0;
} catch (Exception e) {
  Sentry.captureException(e);
}
```

### [Capture a message](https://docs.sentry.io/platforms/android/migration/v1-to-v2.md#capture-a-message)

*Old*:

```java
Sentry.capture("This is a test");
```

*New*:

```java
Sentry.captureMessage("This is a test"); // SentryLevel.INFO by default
Sentry.captureMessage("This is a test", SentryLevel.WARNING); // or specific level
```

### [Breadcrumbs](https://docs.sentry.io/platforms/android/migration/v1-to-v2.md#breadcrumbs)

*Old*:

```java
Sentry.getContext().recordBreadcrumb(
  new BreadcrumbBuilder().setMessage("User made an action").build()
);
```

*New*:

```java
Sentry.addBreadcrumb("User made an action");
```

### [User](https://docs.sentry.io/platforms/android/migration/v1-to-v2.md#user)

*Old*:

```java
Sentry.getContext().setUser(
  new UserBuilder().setEmail("hello@sentry.io").build()
);
```

*New*:

```java
User user = new User();
user.setEmail("hello@sentry.io");
Sentry.setUser(user);
```

### [Set extra](https://docs.sentry.io/platforms/android/migration/v1-to-v2.md#set-extra)

*Old*:

```java
Sentry.getContext().addExtra("extra", "thing");
```

*New*:

```java
Sentry.setExtra("extra", "thing");
```

### [Clear the Context/Scope](https://docs.sentry.io/platforms/android/migration/v1-to-v2.md#clear-the-contextscope)

*Old*:

```java
Sentry.clearContext();
```

*New*:

```java
Sentry.configureScope(s -> s.clear());
```

## [Sentry Gradle Plugin](https://docs.sentry.io/platforms/android/migration/v1-to-v2.md#sentry-gradle-plugin)

Disable the `autoProguardConfig` flag from the Sentry Gradle Plugin since `io.sentry:sentry-android` >= `2.0.0` does this automatically.

```groovy
sentry {
    autoProguardConfig false
}
```
