aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@google.com>2010-01-22 15:52:45 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-01-22 15:52:45 -0800
commit14bf157d4c45ed254730ad8e26a0b1bad5604c34 (patch)
tree945c38fe75a9c9de360e6606bf70ef4960a9b43a
parentf20987a9129ddd5f8911a0371b2f30f939a1ce39 (diff)
parent6dcf4840ca16b16ef27ed25fc3148e1c0db56b35 (diff)
downloadsdk-14bf157d4c45ed254730ad8e26a0b1bad5604c34.zip
sdk-14bf157d4c45ed254730ad8e26a0b1bad5604c34.tar.gz
sdk-14bf157d4c45ed254730ad8e26a0b1bad5604c34.tar.bz2
Merge "Error when building application with package that has a single segment." into eclair
-rw-r--r--anttasks/src/com/android/ant/SetupTask.java15
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/PreCompilerBuilder.java19
2 files changed, 30 insertions, 4 deletions
diff --git a/anttasks/src/com/android/ant/SetupTask.java b/anttasks/src/com/android/ant/SetupTask.java
index f13cccd..72f5d11 100644
--- a/anttasks/src/com/android/ant/SetupTask.java
+++ b/anttasks/src/com/android/ant/SetupTask.java
@@ -264,8 +264,23 @@ public final class SetupTask extends ImportTask {
XPath xPath = AndroidXPathFactory.newXPath();
+ // check the package name.
String value = xPath.evaluate(
"/" + AndroidManifest.NODE_MANIFEST +
+ "/@" + AndroidManifest.ATTRIBUTE_PACKAGE,
+ new InputSource(new FileInputStream(manifest)));
+ if (value != null) { // aapt will complain if it's missing.
+ // only need to check that the package has 2 segments
+ if (value.indexOf('.') == -1) {
+ throw new BuildException(String.format(
+ "Application package '%1$s' must have a minimum of 2 segments.",
+ value));
+ }
+ }
+
+ // check the minSdkVersion value
+ value = xPath.evaluate(
+ "/" + AndroidManifest.NODE_MANIFEST +
"/" + AndroidManifest.NODE_USES_SDK +
"/@" + AndroidXPathFactory.DEFAULT_NS_PREFIX + ":" +
AndroidManifest.ATTRIBUTE_MIN_SDK_VERSION,
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/PreCompilerBuilder.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/PreCompilerBuilder.java
index da73406..ee85e1b 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/PreCompilerBuilder.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/PreCompilerBuilder.java
@@ -406,18 +406,29 @@ public class PreCompilerBuilder extends BaseBuilder {
String msg = String.format(Messages.s_Doesnt_Declare_Package_Error,
AndroidConstants.FN_ANDROID_MANIFEST);
AdtPlugin.printErrorToConsole(project, msg);
- markProject(AndroidConstants.MARKER_ADT, msg, IMarker.SEVERITY_ERROR);
+ BaseProjectHelper.markResource(manifest, AndroidConstants.MARKER_ADT,
+ msg, IMarker.SEVERITY_ERROR);
// This interrupts the build. The next builders will not run.
+ // This also throws an exception and nothing beyond this line will run.
stopBuild(msg);
+ } else if (javaPackage.indexOf('.') == -1) {
+ // The application package name does not contain 2+ segments!
+ String msg = String.format(
+ "Application package '%1$s' must have a minimum of 2 segments.",
+ AndroidConstants.FN_ANDROID_MANIFEST);
+ AdtPlugin.printErrorToConsole(project, msg);
+ BaseProjectHelper.markResource(manifest, AndroidConstants.MARKER_ADT,
+ msg, IMarker.SEVERITY_ERROR);
- // TODO: document whether code below that uses javaPackage (which is now guaranteed
- // to be null) will actually be executed or not.
+ // This interrupts the build. The next builders will not run.
+ // This also throws an exception and nothing beyond this line will run.
+ stopBuild(msg);
}
// at this point we have the java package. We need to make sure it's not a different
// package than the previous one that were built.
- if (javaPackage != null && javaPackage.equals(mManifestPackage) == false) {
+ if (javaPackage.equals(mManifestPackage) == false) {
// The manifest package has changed, the user may want to update
// the launch configuration
if (mManifestPackage != null) {