2

I have created a Cordova App and added a Native module to the Android project.

I have added dependencies for the module to the project, and everything works fine if I use android studio build.

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 fails due to unable to locate module 'mymodule' even if I defined him in settings.gradle.

I tried to find the script that generate the settings.graddle file but without success, maybe I can disable the auto generate method, and use my own setting.graddle.

Could use some help.

cagica
  • 678
  • 4
  • 23
  • I'm having the same problem. Is there any solution for that? – uday Feb 18 '16 at 13:57
  • I couldn't find a solution for this. I keeped using Android Studio build instead of Cordova, just copy the www folder from your project and put it in folder assets of your android project, to update your html. – cagica Feb 18 '16 at 14:05

1 Answers1

1

I'm having the same issue and i found a way to adding native modules in Cordova project. You can use this in feature.

Step 1:
You need build and import the project in Android Studio. For that please follow this.

step 2:
Add a new module to the project. For that please follow this.

step 3:
Find the GradleBuilder.js file in path platforms/android/cordova/lib/builders. In that file, find the function which is writing settings.gradle and add your module like this 'include ":YourModuleName"'.

for older Cordova version the settings.gradle writting function is placed in build.js path is platforms/android/cordova/lib

Now you can build your Cordova project as usual via terminal.

Community
  • 1
  • 1
uday
  • 1,348
  • 12
  • 27