# Add PDF functionality in Android

This guide helps you integrate Nutrient Android SDK into either a new or existing Android project, using Gradle or manual AAR integration. It also shows how to display a PDF using either [`PdfActivity`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.ui/-pdf-activity/index.html) or Jetpack Compose’s [`DocumentView`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.jetpack.compose.views/-document-view.html).

**Jump to example**

Prefer to jump straight to code? View the example repo on GitHub.

[Read more](https://github.com/PSPDFKit/pspdfkit-android-catalog.git)

**Test without installing**

Explore SDK capabilities through our interactive demos.

[Read more](https://www.nutrient.io/guides/android/demo.md)

## Creating or opening your project

If you already have an Android project, open it in Android Studio. Otherwise, create a new one by following the steps below.

**Steps:**

1. Open Android Studio, select **File** > **New** > **New Project**.

2. Choose the **Empty Views Activity** or **Empty Activity** (Jetpack Compose) template.

3. Set your app name (for example, Nutrient Demo), desired save location, language (for example, Kotlin), and minimum SDK (21+ recommended).

4. Click **Finish** to create the project.

## Adding Nutrient to your project

You can add the SDK using Gradle (recommended) or [manually using an AAR file](https://www.nutrient.io/guides/android/advanced-integration/manual-library-integration.md). The Gradle method is outlined below.

**Steps:**

1. In the `settings.gradle.kts` file at the root of your project, add the Nutrient Maven repository:

   ```kotlin

   dependencyResolutionManagement {
       repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
       repositories {
    	   google()
    	   mavenCentral()
    	   maven {
    		   url = uri("https://my.nutrient.io/maven")
    	   }
       }
   }
   ```

2. In your `app/build.gradle.kts` file, add the Nutrient dependency:

   ```kotlin

   dependencies {
      implementation("io.nutrient:nutrient:11.4.0")
   }
   ```

## Configuring your build

Ensure the following configuration in `app/build.gradle.kts`. Note that `compileSdk` and `targetSdk` should be set to the latest available versions:

```kotlin

android {
    compileSdk = <latest>

    defaultConfig {
        applicationId = "com.example.app"
        minSdk = 23
        targetSdk = <latest>
    }

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_17
        targetCompatibility = JavaVersion.VERSION_17
    }

    kotlinOptions {
        jvmTarget = "17"
    }
}

```

> With `minSdk` set to `21`, your app is available on more than [99.4 percent](https://www.appbrain.com/stats/top-android-sdk-versions) of Android devices (as of June 2025).

## Displaying a PDF

You can display PDFs using either [`PdfActivity`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.ui/-pdf-activity/index.html) (classic view system) or [`DocumentView`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.jetpack.compose.views/-document-view.html) (Jetpack Compose).

### PdfActivity (Classic views)

**Steps:**

1. Copy a PDF file to `src/main/assets/my-document.pdf`.

2. Add [`PdfActivity`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.ui/-pdf-activity/index.html) to `AndroidManifest.xml`:

   ```xml

   <application>...

       <activity
           android:name="com.pspdfkit.ui.PdfActivity"
           android:windowSoftInputMode="adjustNothing" />
   </application>
   ```

3. Launch it in your `MainActivity.kt`:

   ```kotlin

   class MainActivity : AppCompatActivity() {
       override fun onCreate(savedInstanceState: Bundle?) {
           super.onCreate(savedInstanceState)
           setContentView(R.layout.activity_main)

           val uri = Uri.parse("file:///android_asset/my-document.pdf")
           val config = PdfActivityConfiguration.Builder(this).build()
           PdfActivity.showDocument(this, uri, config)
       }
   }
   ```

### DocumentView (Jetpack Compose)

**Steps:**

1. Ensure you’re using `AppCompatActivity` and a compatible Compose theme:

   ```xml...
           <activity
               android:name=".MainActivity"...
               android:theme="@style/Theme.AppCompat.NoActionBar">
           </activity>
   <application>
   ```

2. Launch [`DocumentView`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.jetpack.compose.views/-document-view.html) inside your Compose user interface (UI):

   ```kotlin

   class MainActivity : AppCompatActivity() {
       override fun onCreate(savedInstanceState: Bundle?) {
           super.onCreate(savedInstanceState)
           setContent {
               Surface {
                   val uri = Uri.parse("file:///android_asset/my-document.pdf")
                   DocumentView(
                       documentUri = uri,
                       modifier = Modifier.fillMaxSize()
                   )
               }
           }
       }
   }
   ```

> The assets folder is read-only. For writing capabilities, copy PDFs to a writable directory. For more information, refer to our guide on [opening PDFs from URLs](https://www.nutrient.io/guides/android/miscellaneous/document-downloads.md).

## Next steps

- [Customize PdfActivity](https://www.nutrient.io/guides/android/basics/using-activity.md) to match your UI

- Use [`PdfFragment`](https://www.nutrient.io/guides/android/basics/using-fragment/) for modular PDF display

- [Load PDFs from custom sources](https://www.nutrient.io/guides/android/features/data-providers.md)

- [Add collaboration with Instant](https://www.nutrient.io/guides/android/pspdfkit-instant/getting-started.md)

- [Add OCR support](https://www.nutrient.io/guides/android/ocr/getting-started.md)

- Use [`DocumentState`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.jetpack.compose.interactors/-document-state/index.html) with [`DocumentView`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.jetpack.compose.views/-document-view.html) for interaction hooks.