You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2015/08/01 01:33:04 UTC

android commit: CB-9428 update script now bumps up minSdkVersion to 14 if it is less than that.

Repository: cordova-android
Updated Branches:
  refs/heads/master e5506d40b -> 8f7bc1ffb


CB-9428 update script now bumps up minSdkVersion to 14 if it is less than that.


Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/8f7bc1ff
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/8f7bc1ff
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/8f7bc1ff

Branch: refs/heads/master
Commit: 8f7bc1ffbb7ec8238cfa13c164a177f59789dab8
Parents: e5506d4
Author: Steve Gill <st...@gmail.com>
Authored: Fri Jul 31 16:32:41 2015 -0700
Committer: Steve Gill <st...@gmail.com>
Committed: Fri Jul 31 16:32:51 2015 -0700

----------------------------------------------------------------------
 bin/lib/create.js | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/8f7bc1ff/bin/lib/create.js
----------------------------------------------------------------------
diff --git a/bin/lib/create.js b/bin/lib/create.js
index 0815870..e804b6e 100755
--- a/bin/lib/create.js
+++ b/bin/lib/create.js
@@ -290,12 +290,31 @@ function extractProjectNameFromManifest(projectPath) {
     return m[1];
 }
 
+// Cordova-android updates sometimes drop support for older versions. Need to update minSDK in existing projects.
+function updateMinSDKInManifest(projectPath) {
+    var manifestPath = path.join(projectPath, 'AndroidManifest.xml');
+    var manifestData = fs.readFileSync(manifestPath, 'utf8');
+    var minSDKVersion = 14; 
+
+    //grab minSdkVersion from Android.
+    var m = /android:minSdkVersion\s*=\s*"(.*?)"/i.exec(manifestData);
+    if (!m) {
+      throw new Error('Could not find minSDKVersion in ' + manifestPath);
+    }
+    //if minSDKVersion in Android.manifest is less than our current min, replace it
+    if(Number(m[1]) < minSDKVersion) {
+        console.log('Updating minSdkVersion from ' + m[1] + ' to ' + minSDKVersion + ' in AndroidManifest.xml');
+        shell.sed('-i', /android:minSdkVersion\s*=\s*"(.*?)"/, 'android:minSdkVersion="'+minSDKVersion+'"', manifestPath);
+    }
+}
+
 // Returns a promise.
 exports.updateProject = function(projectPath, shared) {
     return Q()
     .then(function() {
         var projectName = extractProjectNameFromManifest(projectPath);
         var target_api = check_reqs.get_target();
+        updateMinSDKInManifest(projectPath);
         copyJsAndLibrary(projectPath, shared, projectName);
         copyScripts(projectPath);
         copyBuildRules(projectPath);


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org