OLD | NEW |
1 Adblock Plus Library for Android | 1 Adblock Plus Library for Android |
2 ================================ | 2 ================================ |
3 | 3 |
4 An Android library project, tests and demo application for AdblockWebView widget
. | 4 An Android library project, tests and demo application for AdblockWebView widget
. |
5 | 5 |
6 ## Updating the dependencies | 6 ## Updating the dependencies |
7 | 7 |
8 Adblock Plus for Android has dependencies that aren't in this repository. | 8 Adblock Plus for Android has dependencies that aren't in this repository. |
9 To update those, call: | 9 To update those, call: |
10 | 10 |
11 ./ensure_dependencies.py | 11 ./ensure_dependencies.py |
12 | 12 |
13 ## Library | 13 ## Library |
14 | 14 |
15 An Android library that provides the core functionality of Adblock Plus. | 15 An Android library that provides the core functionality of Adblock Plus. |
16 You can find it in the 'libadblockplus-android' directory. | 16 You can find it in the 'libadblockplus-android' directory. |
17 | 17 |
18 ### Building with Ant | 18 ### Building |
19 | 19 |
20 #### Requirements | 20 #### Requirements |
21 | 21 |
22 * [The Android SDK](http://developer.android.com/sdk) | |
23 * [The Android NDK, 12b](https://developer.android.com/tools/sdk/ndk) | |
24 * [Ant](http://ant.apache.org) | |
25 | |
26 #### Building | |
27 | |
28 In the 'libadblockplus-android' directory create the file _local.properties_ and
set | |
29 _sdk.dir_ and _ndk.dir_ to where you installed it, e.g.: | |
30 | |
31 sdk.dir = /some/where/sdk | |
32 ndk.dir = /some/where/ndk | |
33 | |
34 Then run: | |
35 | |
36 ant debug | |
37 | |
38 ### Building with Maven | |
39 | |
40 #### Requirements | |
41 | |
42 All 'Building with Ant' requirements and additional requirements: | |
43 | |
44 * [Maven](https://maven.apache.org) | |
45 | |
46 #### Building | |
47 | |
48 Go to android sdk directory '/platforms/android-21' and run: | |
49 | |
50 mvn install:install-file -Dfile=./android.jar -DgroupId=com.google.android -
DartifactId=android | |
51 -Dversion=5.0 -Dpackaging=jar -DgeneratePom=true | |
52 | |
53 Set environment variable ANDROID_HOME to your Android SDK directory or pass it i
n command-line (below). | |
54 In the root directory run: | |
55 | |
56 mvn clean install [-Dandroid.sdk.path=/some/where/sdk] | |
57 | |
58 This will generate *.aar library artifacts in the 'libadblockplus-android/target
', | |
59 'libadblockplus-android-settings/target', 'libadblockplus-android-webview/target
' directories | |
60 and *.apk in the 'libadblockplus-android-webviewapp/target' directory. | |
61 | |
62 ### Building with Gradle/Android Studio | |
63 | |
64 #### Requirements | |
65 | |
66 * [The Android SDK](https://developer.android.com/sdk) | 22 * [The Android SDK](https://developer.android.com/sdk) |
67 * Android SDK Build tools 24.0.1 | 23 * Android SDK Build tools 24.0.1 |
68 * [The Android NDK, 12b](https://developer.android.com/ndk) | 24 * [The Android NDK, 12b](https://developer.android.com/ndk) |
69 | 25 |
70 Edit 'buildToolsVersion' in 'build.gradle' files if necessary. | 26 Edit 'buildToolsVersion' in 'build.gradle' files if necessary. |
71 | 27 |
72 #### Building from command-line | 28 #### Building from command-line |
73 | 29 |
74 In the project root directory create the file _local.properties_ and set | 30 In the project root directory create the file _local.properties_ and set |
75 _sdk.dir_ and _ndk.dir_ to where you installed it, e.g.: | 31 _sdk.dir_ and _ndk.dir_ to where you installed it, e.g.: |
(...skipping 29 matching lines...) Expand all Loading... |
105 | 61 |
106 output while building | 62 output while building |
107 | 63 |
108 ### Building with prebuilt shared V8 | 64 ### Building with prebuilt shared V8 |
109 | 65 |
110 This can be desired to use product's V8 (let's say Chromium) instead of built-in
V8. | 66 This can be desired to use product's V8 (let's say Chromium) instead of built-in
V8. |
111 Put prebuilt shared V8 library file(s) in ARCH directories and set `SHARED_V8_LI
B_FILENAMES` | 67 Put prebuilt shared V8 library file(s) in ARCH directories and set `SHARED_V8_LI
B_FILENAMES` |
112 environment variable before building. You can pass multiple filenames, separated
with space. | 68 environment variable before building. You can pass multiple filenames, separated
with space. |
113 Libadblockplus is required to be linked with that library file(s). | 69 Libadblockplus is required to be linked with that library file(s). |
114 | 70 |
115 For example (build with Gradle): | 71 For example: |
116 | 72 |
117 SHARED_V8_LIB_FILENAMES=libv8.cr.so ./gradlew clean assemble | 73 SHARED_V8_LIB_FILENAMES=libv8.cr.so ./gradlew clean assemble |
118 | 74 |
119 or | 75 or |
120 | 76 |
121 SHARED_V8_LIB_FILENAMES="libv8.cr.so libfoo.so" ./gradlew clean assemble | 77 SHARED_V8_LIB_FILENAMES="libv8.cr.so libfoo.so" ./gradlew clean assemble |
122 | 78 |
123 for multiple library files. | 79 for multiple library files. |
124 | 80 |
125 Note | 81 Note |
(...skipping 26 matching lines...) Expand all Loading... |
152 | 108 |
153 ## Library tests | 109 ## Library tests |
154 | 110 |
155 Android tests for the library. | 111 Android tests for the library. |
156 You can find them in the 'libadblockplus-android-tests' directory. | 112 You can find them in the 'libadblockplus-android-tests' directory. |
157 | 113 |
158 ### Requirements | 114 ### Requirements |
159 | 115 |
160 Make sure _Library_ requirements are present. | 116 Make sure _Library_ requirements are present. |
161 | 117 |
162 ### Building with Ant | 118 ### Building |
163 | |
164 Set ANDROID_HOME environment variable to your Android SDK directory. | |
165 | |
166 In the 'libadblockplus-android-tests' directory run: | |
167 | |
168 ant instrument | |
169 | |
170 ### Testing with Ant | |
171 | |
172 1. Connect an Android device or start the Android Emulator. | |
173 2. In the 'libadblockplus-android-tests' directory run: | |
174 | |
175 ant instrument install test | |
176 | |
177 to build instrumentation tests app and perform testing or run: | |
178 | |
179 ant test | |
180 | |
181 to run installed instrumentation tests app. | |
182 | |
183 To run specific **test** run: | |
184 | |
185 ant testOnly -DtestClass=full.test.class.name | |
186 | |
187 For example: | |
188 | |
189 ant testOnly -DtestClass=org.adblockplus.libadblockplus.tests.NotificationTe
st | |
190 | |
191 To run specific **test method** run: | |
192 | |
193 ant testOnly -DtestClass=full.test.class.name#testMethod | |
194 | |
195 For example: | |
196 | |
197 ant testOnly -DtestClass=org.adblockplus.libadblockplus.tests.NotificationTe
st#testAddNotification | |
198 | |
199 ### Building with Gradle/Android Studio | |
200 | 119 |
201 Make sure you've created the _local.properties_ file to build the library (see a
bove). | 120 Make sure you've created the _local.properties_ file to build the library (see a
bove). |
202 In the project root directory run: | 121 In the project root directory run: |
203 | 122 |
204 ./gradlew assembleDebugAndroidTest | 123 ./gradlew assembleDebugAndroidTest |
205 | 124 |
206 This will generate *.apk in the 'libadblockplus-android-tests/build/outputs/apk/
' directory. | 125 This will generate *.apk in the 'libadblockplus-android-tests/build/outputs/apk/
' directory. |
207 | 126 |
208 ### Testing with Gradle/Android Studio | 127 ### Testing |
209 | 128 |
210 You can select test class/method and click 'Run ..Test'. The library and test ap
p will be | 129 You can select test class/method and click 'Run ..Test'. The library and test ap
p will be |
211 compiled, installed to emulator/device and launched automatically. | 130 compiled, installed to emulator/device and launched automatically. |
212 | 131 |
213 ## Settings | 132 ## Settings |
214 | 133 |
215 An Android library that provides a configuration interface for Adblock Plus. | 134 An Android library that provides a configuration interface for Adblock Plus. |
216 You can find it in the 'libadblockplus-android-settings' directory: | 135 You can find it in the 'libadblockplus-android-settings' directory: |
217 * GeneralSettingsFragment - main fragment | 136 * GeneralSettingsFragment - main fragment |
218 * WhitelistedDomainsSettingsFragment - whitelisted domains fragment | 137 * WhitelistedDomainsSettingsFragment - whitelisted domains fragment |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 AdblockHelper.get().waitForReady(); | 171 AdblockHelper.get().waitForReady(); |
253 | 172 |
254 Release Adblock instance in activity `onDestroy`: | 173 Release Adblock instance in activity `onDestroy`: |
255 | 174 |
256 AdblockHelper.get().release(); | 175 AdblockHelper.get().release(); |
257 | 176 |
258 Insert `GeneralSettingsFragment` fragment instance in runtime to start showing s
ettings UI. | 177 Insert `GeneralSettingsFragment` fragment instance in runtime to start showing s
ettings UI. |
259 | 178 |
260 ### Building | 179 ### Building |
261 | 180 |
262 #### Building with Ant | |
263 | |
264 In the 'libadblockplus-android-settings' directory create the file _local.proper
ties_ and set | |
265 _sdk.dir_ to where you installed it, e.g.: | |
266 | |
267 sdk.dir = /some/where/sdk | |
268 | |
269 Then run: | |
270 | |
271 ant debug | |
272 | |
273 | |
274 #### Building with Gradle | |
275 | |
276 In the project root directory run: | 181 In the project root directory run: |
277 | 182 |
278 ./gradlew assemble | 183 ./gradlew assemble |
279 | 184 |
280 This will generate *.aar in the 'libadblockplus-android-settings/build/outputs/a
ar' directory. | 185 This will generate *.aar in the 'libadblockplus-android-settings/build/outputs/a
ar' directory. |
281 | 186 |
282 ## WebView | 187 ## WebView |
283 | 188 |
284 An Android library that provides a WebView component with Adblock Plus integrate
d. | 189 An Android library that provides a WebView component with Adblock Plus integrate
d. |
285 You can find it in the 'libadblockplus-android-webview' directory. | 190 You can find it in the 'libadblockplus-android-webview' directory. |
(...skipping 22 matching lines...) Expand all Loading... |
308 Use `setAllowDrawDelay(int allowDrawDelay)` to set custom delay to start render
webpage after 'DOMContentLoaded' event is fired. | 213 Use `setAllowDrawDelay(int allowDrawDelay)` to set custom delay to start render
webpage after 'DOMContentLoaded' event is fired. |
309 | 214 |
310 Use `setAdblockEngine(AdblockEngine adblockEngine)` to use external adblock engi
ne. | 215 Use `setAdblockEngine(AdblockEngine adblockEngine)` to use external adblock engi
ne. |
311 If adblock engine is not set, it's created by AdblockWebView instance automatica
lly. | 216 If adblock engine is not set, it's created by AdblockWebView instance automatica
lly. |
312 | 217 |
313 Use `dispose(Runnable disposeFinished)` to release resources (**required**). | 218 Use `dispose(Runnable disposeFinished)` to release resources (**required**). |
314 Note it can be invoked from background thread. | 219 Note it can be invoked from background thread. |
315 | 220 |
316 ### Building | 221 ### Building |
317 | 222 |
318 #### Building with Ant | |
319 | |
320 In the 'libadblockplus-android-webview' directory create the file _local.propert
ies_ and set | |
321 _sdk.dir_ to where you installed it, e.g.: | |
322 | |
323 sdk.dir = /some/where/sdk | |
324 | |
325 Then run: | |
326 | |
327 ant debug | |
328 | |
329 | |
330 #### Building with Gradle | |
331 | |
332 In the project root directory run: | 223 In the project root directory run: |
333 | 224 |
334 ./gradlew assemble | 225 ./gradlew assemble |
335 | 226 |
336 This will generate *.aar in the 'libadblockplus-android-webview/build/outputs/aa
r' directory. | 227 This will generate *.aar in the 'libadblockplus-android-webview/build/outputs/aa
r' directory. |
337 | 228 |
338 ## WebView Application | 229 ## WebView Application |
339 | 230 |
340 An Android application that demonstrates how to use AdblockWebView. | 231 An Android application that demonstrates how to use AdblockWebView. |
341 You can find it in the 'libadblockplus-android-webviewapp' directory. | 232 You can find it in the 'libadblockplus-android-webviewapp' directory. |
342 | 233 |
343 ### Building | 234 ### Building |
344 | 235 |
345 Make sure _Library_ requirements are present. | 236 Make sure _Library_ requirements are present. |
346 | 237 |
347 #### Building with Ant | |
348 | |
349 In the 'libadblockplus-android-webviewapp' directory create the file _local.prop
erties_ and set | |
350 _sdk.dir_ to where you installed it, e.g.: | |
351 | |
352 sdk.dir = /some/where/sdk | |
353 | |
354 Then run: | |
355 | |
356 ant debug | |
357 | |
358 This will generate *.apk in the 'libadblockplus-android-webviewapp/bin/' directo
ry. | |
359 | |
360 #### Building with Gradle | |
361 | |
362 In the project root directory run: | 238 In the project root directory run: |
363 | 239 |
364 ./gradlew assemble | 240 ./gradlew assemble |
365 | 241 |
366 This will generate *.apk in the 'libadblockplus-android-webviewapp/build/outputs
/apk/' directory. | 242 This will generate *.apk in the 'libadblockplus-android-webviewapp/build/outputs
/apk/' directory. |
OLD | NEW |