how to add to settings.gradle in cordova

Multi tool use
Multi tool use


how to add to settings.gradle in cordova



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.





I'm having my own difficulties trying to get a multi-project setup going with additional modules. Again, this requires the ability to modify the settings.gradle file, however it does not appear that cordova provides any ability to control the contents of this file.
– Chris Noldus
Jun 1 '16 at 0:22




2 Answers
2



You can include or exclude dependency using build-extras.gradle file. This file can be added along with build.gradle file in the same location using before_build hook action.


build-extras.gradle


build.gradle


before_build



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.





The settings.gradle file is different from the build.gradle file, the official documentation does not provide any insight as to how one might be able to add directives to the settings.gradle file.
– Chris Noldus
Jun 1 '16 at 0:16






@ChrisNoldus Hi Chris,I do understand settings.gradle is different from build,gradle and in official documentation there is no insight of the same. But as far as i investigated, there is no direct way of editing settings.gradle file with the exception of manipulating it through build.gradle. Request you to check out this link too - discuss.gradle.org/t/… But if you are still concerned about modifying setting.gradle file, have updates the quick fix to in my updated answer. Request-Kindly reconsider before down voting as it demotivates us.
– Gandhi
Jun 1 '16 at 2:34





@Ghandi - appreciate the effort, the downvote was originally because your answer does not answer the question - of course I assumed the asker has looked at the documentation and trying to do the same as me. As this may not be the case, downvote removed.
– Chris Noldus
Jun 1 '16 at 3:28





@Chris Thanks Chris. Hope my answer makes more sense now. Thanks again for helping me in refining the answer
– Gandhi
Jun 1 '16 at 3:34





This was partially correct once i had this information i was able to add the Library via plugin.xml <framework src="src/android/somecode" custom="true" /> this added what i needed to settings.gradle then i was able to also add a build-extras.gradle in the plugin because cordova overwrites the build.gradle in the sub project so the sub-project specific things needed added back in
– Nathan
Jun 9 '16 at 18:37




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 after CordovaLib:


project.properties


CordovaLib


target=android-25
android.library.reference.1=CordovaLib
android.library.reference.2=libraryModule1
android.library.reference.3=libraryModule2



Step-2. Run cordova build android. This will make an entry in your setting.gradle file.


cordova build android


setting.gradle


//GENERATED FILE - DO NOT EDIT
include ":"
include ":CordovaLib"
include ":libraryModule1"
include ":libraryModule2"



Also your app build.gradle will look like this:


build.gradle


dependencies {
----
// SUB-PROJECT DEPENDENCIES START
debugCompile(project(path: "CordovaLib", configuration: "debug"))
releaseCompile(project(path: "CordovaLib", configuration: "release"))
debugCompile(project(path: "libraryModule1", configuration: "debug"))
releaseCompile(project(path: "libraryModule1", configuration: "release"))
debugCompile(project(path: "libraryModule2", configuration: "debug"))
releaseCompile(project(path: "libraryModule2", configuration: "release"))
----
// SUB-PROJECT DEPENDENCIES END
}






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

5H2Lb ojrBuTOQWaO,n2Js4975P0itYoaHaE,Ve
M78B K9fP3vTle I,zI7AU Rd6D2TMWjMTkyFGrWgeZ qfoyKz4HYRfzaPFGReTdYNBFgT35O7m6UQ6W,0K9XWuNngWJo 2eRtFY

Popular posts from this blog

PHP contact form sending but not receiving emails

Do graphics cards have individual ID by which single devices can be distinguished?

Create weekly swift ios local notifications