Skip to content

Commit 71a3fb8

Browse files
committed
Update README.md for Android with simpler integration process using Maven
1 parent ff641cd commit 71a3fb8

File tree

1 file changed

+29
-52
lines changed

1 file changed

+29
-52
lines changed

README.md

Lines changed: 29 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -111,64 +111,42 @@ PSPDFKit.present('document.pdf', {
111111
- Android SDK
112112
- Android Build Tools 23.0.1 (React Native)
113113
- Android Build Tools 25.0.2 (PSPDFKit module)
114-
- PSPDFKit >= 2.9.3
114+
- PSPDFKit >= 3.0.0
115115
- react-native >= 0.41.2
116116

117117
#### Getting Started
118118

119-
Let's create a simple app that integrates `pspdfkit-*.aar` and uses the react-native-pspdfkit module.
119+
Let's create a simple app that integrates PSPDFKit and uses the react-native-pspdfkit module.
120120

121121
1. Make sure `react-native-cli` is installed: `yarn global add react-native-cli`
122122
2. Create the app with `react-native init YourApp`.
123123
3. Step into your newly created app folder: `cd YourApp`.
124124
4. Install `react-native-pspdfkit` from GitHub: `yarn add github:PSPDFKit/react-native`.
125-
5. Link module `react-native-pspdfkit`: `react-native link react-native-pspdfkit`.
126-
6. Add dependencies to `YourApp/node_modules/react-native-pspdfkit/android/build.gradle`.
127-
128-
A complete list of the dependencies needed can be found in the [documentation](https://pspdfkit.com/guides/android/current/getting-started/integrating-pspdfkit/#toc_manual-library-file-integration) step 6, under `Manual library file integration`.
129-
For PSPDFKit 2.9.3 :
130-
131-
```
132-
dependencies {
133-
...
134-
//compile 'com.pspdfkit:pspdfkit:2.9.3@aar' <-- DO NOT ADD THE LIBRARY ITSELF
135-
compile 'com.android.support:support-v4:25.1.+'
136-
compile 'com.android.support:appcompat-v7:25.1.+'
137-
compile "com.android.support:recyclerview-v7:25.1.+"
138-
compile "com.android.support:cardview-v7:25.1.+"
139-
compile "com.android.support:design:25.1.+"
140-
compile 'io.reactivex:rxjava:1.2.6'
141-
compile 'io.reactivex:rxandroid:1.2.1'
142-
compile 'com.getkeepsafe.relinker:relinker:1.2.2'
143-
}
125+
5. Link module `react-native-pspdfkit`: `react-native link react-native-pspdfkit`.
126+
6. Add PSPDFKit repository to `YourApp/android/build.gradle` so PSPDFKit library can be downloaded:
127+
128+
```diff
129+
allprojects {
130+
repositories {
131+
mavenLocal()
132+
jcenter()
133+
+ maven {
134+
+ url 'https://customers.pspdfkit.com/maven/'
135+
136+
+ credentials {
137+
+ username 'pspdfkit'
138+
+ password 'YOUR_MAVEN_KEY_GOES_HERE'
139+
+ }
140+
+ }
141+
maven {
142+
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
143+
url "$rootDir/../node_modules/react-native/android"
144+
}
145+
}
146+
}
144147
```
145148

146-
7. Add the following lines to `YourApp/android/settings.gradle` file:
147-
148-
```
149-
include ':pspdfkit-lib'
150-
```
151-
152-
8. Create new `pspdfkit-lib` folder in `YourApp/android`.
153-
9. Create new `build.gradle` file in `YourApp/android/pspdfkit-lib` and add the following lines:
154-
155-
```
156-
configurations.maybeCreate("default")
157-
def library = fileTree(".").filter { it.isFile() }.filter { it.name.endsWith('.aar') }.files.name.first()
158-
artifacts.add("default", file(library))
159-
```
160-
161-
10. Copy `pspdfkit-*.aar` library in `YourApp/android/pspdfkit-lib`.
162-
11. Add the following dependencies to `YourApp/android/app/build.gradle` file:
163-
164-
```
165-
dependencies {
166-
...
167-
compile project(':pspdfkit-lib')
168-
}
169-
```
170-
171-
And modify the following lines (note **three** places to edit):
149+
7. PSPDFKit targets modern platforms, so you'll have to update `compileSdkVersion` and `targetSdkVersion` to at least API 25 (note **three** places to edit):
172150

173151
```diff
174152
...
@@ -192,15 +170,15 @@ artifacts.add("default", file(library))
192170
...
193171
```
194172
195-
12. Set primary color. In `YourApp/android/app/src/main/res/values/styles.xml` replace
173+
8. Set primary color. In `YourApp/android/app/src/main/res/values/styles.xml` replace
196174
```xml
197175
<!-- Customize your theme here. -->
198176
```
199177
with
200178
```xml
201179
<item name="colorPrimary">#3C97C9</item>
202180
```
203-
13. Replace the default component from `YourApp/index.android.js` with a simple touch area to present a PDF document from the local device filesystem:
181+
9. Replace the default component from `YourApp/index.android.js` with a simple touch area to present a PDF document from the local device filesystem:
204182

205183
```javascript
206184
import React, { Component } from 'react';
@@ -224,7 +202,6 @@ with
224202
pageScrollDirection : "vertical"
225203
};
226204

227-
PSPDFKit.setLicenseKey(LICENSE);
228205
// Change 'YourApp' to your app's name.
229206
class YourApp extends Component {
230207
_onPressButton() {
@@ -276,13 +253,13 @@ with
276253
// Change both 'YourApp's to your app's name.
277254
AppRegistry.registerComponent('YourApp', () => YourApp);
278255
```
279-
14. Before launching the app you need to copy a PDF document onto your development device or emulator.
256+
10. Before launching the app you need to copy a PDF document onto your development device or emulator.
280257

281258
```bash
282259
adb push /path/to/your/document.pdf /sdcard/document.pdf
283260
```
284261

285-
15. Your app is now ready to launch. From `YourApp` directory run `react-native run-android`.
262+
11. Your app is now ready to launch. From `YourApp` directory run `react-native run-android`.
286263

287264
```bash
288265
react-native run-android

0 commit comments

Comments
 (0)