You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: www/docs/en/dev/guide/platforms/android/index.md
+22-11Lines changed: 22 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -477,7 +477,7 @@ You can set these properties in one of four ways:
477
477
cdvMinSdkVersion=20
478
478
```
479
479
480
-
- [Extending `build.gradle`](#extending-buildgradle) with the `build-extras.gradle file
480
+
- [Extending `build.gradle`](#extending-buildgradle) with the `build-extras.gradle` file
481
481
482
482
Create a file named `build-extras.gradle` in the directory `<project-root>/platforms/android/app` with the contents such as:
483
483
@@ -487,14 +487,31 @@ You can set these properties in one of four ways:
487
487
488
488
The latter two options both involve including an extra file in your Android platform folder. In general, it is discouraged to edit the contents of this folder because it is easy for those changes to be lost or overwritten. Instead, these files should be copied into the folder as part of the build command by using the `before_build` [hook script](../../appdev/hooks/index.html).
489
489
490
-
#### Extending build.gradle
490
+
#### Extending `build.gradle`
491
491
492
-
If you need to customize the `build.gradle` file, rather than edit it directly, it is recommended to create a sibling file named `build-extras.gradle`. This file will be included by the main `build.gradle` script when present. This file must be placed in the `app` folder of the Android's platform directory (`<your-project>/platforms/android/app`). It is recommended to use the `before_build` [hook script](../../appdev/hooks/index.html) to copy this file over.
492
+
To customize the `app/build.gradle` file without modifying it directly, create a sibling file named `build-extras.gradle`.
493
493
494
-
Here's an example:
494
+
If this file exists in the `<your-project>/platforms/android/app` directory during the build process, it will be automatically applied by the app's `build.gradle` script.
495
+
496
+
To automate placing `build-extras.gradle`in the correct location, use the `<resource-file>` element in`config.xml`.
497
+
498
+
In the example below, the source`build-extras.gradle` is saved in a `res/` directory in the project root. It is then declared in`config.xml` to copy it to the appropriate target location:
**Note:** The `res/` directory name is just an example. You can use any directory and file name you prefer. However, it's recommended not to place the file inside the `platforms`, `plugins`, or `www` directories. Also, make sure the `target` path matches exactly as shown in the example.
505
+
506
+
**Note:** Plugin developers can also include a `build-extras.gradle` file, but should use the `<framework>` element in `plugin.xml` instead of `<resource-file>`:
To change the Gradle JVM args, the `--jvmargs` flag can be used with both Cordova's `build` and `run` commands. This is mostly useful for controlling how much memory gradle is allowed to use during the build process. It is recommended to allow at least 2048 MB.
0 commit comments