aboutsummaryrefslogtreecommitdiffstats
path: root/sdkmanager/app
diff options
context:
space:
mode:
authorRaphael <raphael@google.com>2009-10-21 12:30:21 -0700
committerRaphael <raphael@google.com>2009-10-21 12:52:11 -0700
commit5ffaec4a2ca90d40d63d01aedbed7980c835938f (patch)
tree011818eb3ad9ff3a78629709f8a2f62e8ea5096e /sdkmanager/app
parent4b85c08b422e23c0808232eded2e91c29cbed1f1 (diff)
downloadsdk-5ffaec4a2ca90d40d63d01aedbed7980c835938f.zip
sdk-5ffaec4a2ca90d40d63d01aedbed7980c835938f.tar.gz
sdk-5ffaec4a2ca90d40d63d01aedbed7980c835938f.tar.bz2
SDK android "update project" must not require --target parameter.
SDK BUG 2203846 Change-Id: I235da4a8892de9a4334d5630667484220472f168
Diffstat (limited to 'sdkmanager/app')
-rw-r--r--sdkmanager/app/src/com/android/sdkmanager/Main.java26
1 files changed, 15 insertions, 11 deletions
diff --git a/sdkmanager/app/src/com/android/sdkmanager/Main.java b/sdkmanager/app/src/com/android/sdkmanager/Main.java
index 84195d1..55d4357 100644
--- a/sdkmanager/app/src/com/android/sdkmanager/Main.java
+++ b/sdkmanager/app/src/com/android/sdkmanager/Main.java
@@ -291,11 +291,11 @@ public class Main {
// get the target and try to resolve it.
int targetId = resolveTargetName(mSdkCommandLine.getParamTargetId());
IAndroidTarget[] targets = mSdkManager.getTargets();
- if (targetId < 1 || targetId > targets.length) {
+ if (targetId == INVALID_TARGET_ID || targetId > targets.length) {
errorAndExit("Target id is not valid. Use '%s list targets' to get the target ids.",
SdkConstants.androidCmdName());
}
- IAndroidTarget target = targets[targetId - 1];
+ IAndroidTarget target = targets[targetId - 1]; // target id is 1-based
ProjectCreator creator = new ProjectCreator(mOsSdkFolder,
mSdkCommandLine.isVerbose() ? OutputLevel.VERBOSE :
@@ -462,14 +462,18 @@ public class Main {
private void updateProject() {
// get the target and try to resolve it.
IAndroidTarget target = null;
- int targetId = resolveTargetName(mSdkCommandLine.getParamTargetId());
- if (targetId >= 0) {
+ String targetStr = mSdkCommandLine.getParamTargetId();
+ // For "update project" the target parameter is optional so having null is acceptable.
+ // However if there's a value, it must be valid.
+ if (targetStr != null) {
IAndroidTarget[] targets = mSdkManager.getTargets();
- if (targetId < 1 || targetId > targets.length) {
- errorAndExit("Target id is not valid. Use '%s list targets' to get the target ids.",
+ int targetId = resolveTargetName(targetStr);
+ if (targetId == INVALID_TARGET_ID || targetId > targets.length) {
+ errorAndExit("Target id '%1$s' is not valid. Use '%2$s list targets' to get the target ids.",
+ targetStr,
SdkConstants.androidCmdName());
}
- target = targets[targetId - 1];
+ target = targets[targetId - 1]; // target id is 1-based
}
ProjectCreator creator = new ProjectCreator(mOsSdkFolder,
@@ -715,15 +719,15 @@ public class Main {
private void createAvd() {
// find a matching target
int targetId = resolveTargetName(mSdkCommandLine.getParamTargetId());
- IAndroidTarget target = null;
+ IAndroidTarget[] targets = mSdkManager.getTargets();
- if (targetId >= 1 && targetId <= mSdkManager.getTargets().length) {
- target = mSdkManager.getTargets()[targetId-1]; // target it is 1-based
- } else {
+ if (targetId == INVALID_TARGET_ID || targetId > targets.length) {
errorAndExit("Target id is not valid. Use '%s list targets' to get the target ids.",
SdkConstants.androidCmdName());
}
+ IAndroidTarget target = targets[targetId-1]; // target id is 1-based
+
try {
boolean removePrevious = mSdkCommandLine.getFlagForce();
AvdManager avdManager = new AvdManager(mSdkManager, mSdkLog);