aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AdtPlugin.java15
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/newproject/NewProjectWizard.java37
2 files changed, 42 insertions, 10 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AdtPlugin.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AdtPlugin.java
index 6208b45..d10b981 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AdtPlugin.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AdtPlugin.java
@@ -507,7 +507,8 @@ public class AdtPlugin extends AbstractUIPlugin {
return total.toString();
}
} catch (IOException e) {
- // we'll just return null;.
+ // we'll just return null
+ AdtPlugin.log(e, "Failed to read text file '%s'", filepath); //$NON-NLS-1$
}
return null;
@@ -538,6 +539,7 @@ public class AdtPlugin extends AbstractUIPlugin {
}
} catch (IOException e) {
// we'll just return null;.
+ AdtPlugin.log(e, "Failed to read binary file '%s'", filepath); //$NON-NLS-1$
}
return null;
@@ -558,8 +560,10 @@ public class AdtPlugin extends AbstractUIPlugin {
}
} catch (MalformedURLException e) {
// we'll just return null.
+ AdtPlugin.log(e, "Failed to read stream '%s'", filepath); //$NON-NLS-1$
} catch (IOException e) {
// we'll just return null;.
+ AdtPlugin.log(e, "Failed to read stream '%s'", filepath); //$NON-NLS-1$
}
return null;
@@ -581,7 +585,14 @@ public class AdtPlugin extends AbstractUIPlugin {
}
// attempt to get a file to one of the template.
- return bundle.getEntry(AndroidConstants.WS_SEP + filepath);
+ String path = AndroidConstants.WS_SEP + filepath;
+ URL url = bundle.getEntry(path);
+
+ if (url == null) {
+ AdtPlugin.log(IStatus.INFO, "Bundle file URL not found at path '%s'", path);
+ }
+
+ return url;
}
/**
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/newproject/NewProjectWizard.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/newproject/NewProjectWizard.java
index 39be01c..517ffa0 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/newproject/NewProjectWizard.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/newproject/NewProjectWizard.java
@@ -760,6 +760,15 @@ public class NewProjectWizard extends Wizard implements INewWizard {
// Replace all keyword parameters
manifestTemplate = replaceParameters(manifestTemplate, parameters);
+ if (manifestTemplate == null) {
+ // Inform the user there will be not manifest.
+ AdtPlugin.logAndPrintError(null, getWindowTitle() /*TAG*/,
+ "Failed to generate the Android manifest. Missing template %s",
+ TEMPLATE_MANIFEST);
+ // Abort now, there's no need to continue
+ return;
+ }
+
if (parameters.containsKey(PARAM_ACTIVITY)) {
// now get the activity template
String activityTemplate = AdtPlugin.readEmbeddedTextFile(TEMPLATE_ACTIVITIES);
@@ -770,11 +779,15 @@ public class NewProjectWizard extends Wizard implements INewWizard {
// set the intent.
String intent = AdtPlugin.readEmbeddedTextFile(TEMPLATE_INTENT_LAUNCHER);
- // set the intent to the main activity
- activities = activities.replaceAll(PH_INTENT_FILTERS, intent);
+ if (activities != null) {
+ if (intent != null) {
+ // set the intent to the main activity
+ activities = activities.replaceAll(PH_INTENT_FILTERS, intent);
+ }
- // set the activity(ies) in the manifest
- manifestTemplate = manifestTemplate.replaceAll(PH_ACTIVITIES, activities);
+ // set the activity(ies) in the manifest
+ manifestTemplate = manifestTemplate.replaceAll(PH_ACTIVITIES, activities);
+ }
} else {
// remove the activity(ies) from the manifest
manifestTemplate = manifestTemplate.replaceAll(PH_ACTIVITIES, ""); //$NON-NLS-1$
@@ -784,11 +797,17 @@ public class NewProjectWizard extends Wizard implements INewWizard {
if (parameters.containsKey(PARAM_TEST_TARGET_PACKAGE)) {
// Set the uses-library needed by the test project
String usesLibrary = AdtPlugin.readEmbeddedTextFile(TEMPLATE_TEST_USES_LIBRARY);
- manifestTemplate = manifestTemplate.replaceAll(PH_TEST_USES_LIBRARY, usesLibrary);
+ if (usesLibrary != null) {
+ manifestTemplate = manifestTemplate.replaceAll(
+ PH_TEST_USES_LIBRARY, usesLibrary);
+ }
// Set the instrumentation element needed by the test project
String instru = AdtPlugin.readEmbeddedTextFile(TEMPLATE_TEST_INSTRUMENTATION);
- manifestTemplate = manifestTemplate.replaceAll(PH_TEST_INSTRUMENTATION, instru);
+ if (instru != null) {
+ manifestTemplate = manifestTemplate.replaceAll(
+ PH_TEST_INSTRUMENTATION, instru);
+ }
// Replace PARAM_TEST_TARGET_PACKAGE itself now
manifestTemplate = replaceParameters(manifestTemplate, parameters);
@@ -802,8 +821,10 @@ public class NewProjectWizard extends Wizard implements INewWizard {
String minSdkVersion = (String) parameters.get(PARAM_MIN_SDK_VERSION);
if (minSdkVersion != null && minSdkVersion.length() > 0) {
String usesSdkTemplate = AdtPlugin.readEmbeddedTextFile(TEMPLATE_USES_SDK);
- String usesSdk = replaceParameters(usesSdkTemplate, parameters);
- manifestTemplate = manifestTemplate.replaceAll(PH_USES_SDK, usesSdk);
+ if (usesSdkTemplate != null) {
+ String usesSdk = replaceParameters(usesSdkTemplate, parameters);
+ manifestTemplate = manifestTemplate.replaceAll(PH_USES_SDK, usesSdk);
+ }
} else {
manifestTemplate = manifestTemplate.replaceAll(PH_USES_SDK, "");
}