Skip to content

Commit d30e0cd

Browse files
authored
Merge pull request #482 from jasonz1987/develop
fix cordova-android 7.0 install bug
2 parents 799dfa7 + dfe64ed commit d30e0cd

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

scripts/android-install.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ module.exports = function (context) {
44
var path = context.requireCordovaModule('path'),
55
fs = context.requireCordovaModule('fs'),
66
shell = context.requireCordovaModule('shelljs'),
7+
semver = context.requireCordovaModule('semver'),
78
projectRoot = context.opts.projectRoot,
89
plugins = context.opts.plugins || [];
910

@@ -40,7 +41,20 @@ module.exports = function (context) {
4041
}
4142

4243
var targetDir = path.join(projectRoot, "platforms", "android", "src", packageName.replace(/\./g, path.sep), "wxapi");
43-
targetFiles = ["EntryActivity.java", "WXEntryActivity.java", "WXPayEntryActivity.java"];
44+
45+
var engines = config.getEngines();
46+
engines.forEach(function(item,index) {
47+
if(item.name == 'android') {
48+
var sepc = item.spec.replace('~','').replace('^','');
49+
console.log(sepc);
50+
if (semver.gt(sepc,'7.0.0')) {
51+
console.info("Android platform Version above 7.0.0");
52+
targetDir = path.join(projectRoot, "platforms", "android", "app", "src", "main", "java", packageName.replace(/\./g, path.sep), "wxapi");
53+
}
54+
}
55+
});
56+
57+
var targetFiles = ["EntryActivity.java", "WXEntryActivity.java", "WXPayEntryActivity.java"];
4458

4559
if (['after_plugin_add', 'after_plugin_install'].indexOf(context.hook) === -1) {
4660
// remove it?

0 commit comments

Comments
 (0)