Manual Library Integration

PSPDFKit for Android can be imported manually. Below are the steps to follow if you wish to do so,

  1. In your web browser, log in to https://customers.pspdfkit.com and navigate to the Your Licenses & Keys page. If you don’t yet have a customer account, you can also get an evaluation license.

  2. Locate your Android license and click Download PSPDFKit for Android.

  3. Download the PSPDFKit library .zip bundle and extract it.

  4. Copy the PSPDFKit AAR file into your project’s libs directory.

  5. Include PSPDFKit as a file-based dependency in your project, and provide all the transitive dependencies required by PSPDFKit (as shown below):

    Copy
    build.gradle
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    
    dependencies {
        implementation files('libs/pspdfkit-6.4.0.aar')
    
        // You must include all transitive dependencies of PSPDFKit.
        implementation 'androidx.legacy:legacy-support-v4:1.0.0'
        implementation 'androidx.appcompat:appcompat:1.1.0'
        implementation 'androidx.recyclerview:recyclerview:1.0.0'
        implementation 'androidx.cardview:cardview:1.0.0'
        implementation 'androidx.palette:palette:1.0.0'
        implementation 'androidx.exifinterface:exifinterface:1.0.0'
        implementation 'androidx.gridlayout:gridlayout:1.0.0'
        implementation 'com.google.android.material:material:1.2.0-alpha01'
        implementation 'io.reactivex.rxjava2:rxjava:2.2.7'
        implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
        implementation 'com.getkeepsafe.relinker:relinker:1.4.1'
        implementation 'com.facebook.device.yearclass:yearclass:2.0.0'
        implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.3.71'
    }
    

ℹ️ Note: Starting with the Android Gradle plugin 3.5.0, the use of flatDir repositories to include local AAR files is no longer supported. If you have been using this technique, you need to migrate to file-based dependencies when updating the Android Gradle plugin to 3.5.0.

The following optional libraries are included in the list of transitive dependencies:

  • ReLinker — to work around some versions of Android that have unreliable PackageManager implementations.
  • Device Year Class — to optimize the low-resolution render strategy based on device specs and performance.

These optional libraries can be omitted from the list of transitive dependencies if you don’t want to bundle them with your app. In such a case, PSPDFKit will detect the absence of these dependencies and will fall back to different implementations.

ProGuard

There is no need to specify additional ProGuard rules since PSPDFKit uses consumersProguardFiles to keep ProGuard from obfuscating the required symbols. If you want to check out the rules, you should take a look at proguard.txt, which is located inside the PSPDFKit .aar:

1
2
3
    cd [YOUR_AAR_LOCATION]
    unzip [YOUR_AAR_NAME].aar -d aar-contents
    cat aar-contents/proguard.txt