This is the same question I am to new to comment on it to see if he found a answer
Cordova is generating a new settings.gradle file when you run "cordova build android" I have attempted using a script to modify this file using hooks after _prepare before_compile. but no matter what i do this file is recreated. Has anyone solved this problem? is there another way to add a module to the android project? besides using the settings.gradle
I knwo next to nothing about java or Gradle so any in-site would be great.
You can include or exclude dependency using
build-extras.gradle
file. This file can be added along withbuild.gradle
file in the same location usingbefore_build
hook action.Request you to check Official Cordova documentation for more info on the same. Also check out this example which explains exclusion of duplicate modules. The same can be extended for module inclusion as well.
Updated: I do understand that the question is about settings.gradle and I m talking about build.gradle. That's because as far as i know, there is no way of directly manipulating settings.gradle with the exception of through build.gradle as its explained in the example link. Also i suggest you to have a look at this gradle thread which explains adding dependency via build.gradle file.
But if you are still looking for a solution to manipulate settings.gradle, you gotta edit build.js file in android platform as suggested in this post which is more of a quick fix or tweak.
I hope it helps.
Today i faced the same problem and by spending hours i found that we can do this by change in project.properties
Below are the steps:
Step-1. Edit/Make
project.properties
in root directory and add your module as library reference afterCordovaLib
:Step-2. Run
cordova build android
. This will make an entry in yoursetting.gradle
file.Also your app
build.gradle
will look like this: