ionic框架Android平台,添加第三方module引用

1.  android平台目录下的settings.gradle里面的默认内容是 

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

如果直接修改此文件添加module引用,下次ionic cordova build android 命令,会复原回上面的配置

所以需要在其他地方修改

打开下面路径文件

android/cordova/lib/builders/GradleBuilder.js

找到这个地方 

// Write the settings.gradle file.
fs.writeFileSync(path.join(this.root, 'settings.gradle'),
'// GENERATED FILE - DO NOT EDIT\n' +
'include ":"\n' + settingsGradlePaths.join(''));

在 'include ":"\n' 中间加入自己的第三方的引用 'include ":",":framework"\n'

最终效果

// Write the settings.gradle file.
fs.writeFileSync(path.join(this.root, 'settings.gradle'),
'// GENERATED FILE - DO NOT EDIT\n' +
'include ":",":framework"\n' + settingsGradlePaths.join(''));


2. android平台目录下的build.gradle文件,在 dependencies 内容里面添加 compile(project(path: "framework"));

最终效果

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(path: "framework"));
}