I have created a Cordova App with a custom settings.gradle as folows:
// GENERATED FILE - DO NOT EDIT
include ":"
include ":CordovaLib"
include 'manager'
project(':manager').projectDir = new File('libs/ConnectManager')
and in build.gradle, I can refer to it as:
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
// SUB-PROJECT DEPENDENCIES START
debugCompile project(path: "CordovaLib", configuration: "debug")
releaseCompile project(path: "CordovaLib", configuration: "release")
// SUB-PROJECT DEPENDENCIES END
compile project(':manager')
}
However, when I execute command 'cordova build android', the file settings.gradle is auto-generated to a default setting which looks like:
// GENERATED FILE - DO NOT EDIT
include ":"
include ":CordovaLib"
As a result, build always failed due to unable to locate module 'manager' that I have defined in settings.gradle.
I wonder if there is any way to prevent build command from duplicating a custom settings.gradle file.
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:For
project(':manager').projectDir = new File('libs/ConnectManager')
this kind of setting there is no easy way i found but you can achieve in this way:Step-1. /path/to/project/platforms/android/cordova/lib/builders/GradleBuilder.js
Step-2. Edit fs.writeFileSync() function(Line-100)