OSDN Git Service

Fix NPE when building project with no code.
authorXavier Ducrohet <xav@android.com>
Sat, 15 Oct 2011 00:57:35 +0000 (17:57 -0700)
committerXavier Ducrohet <xav@android.com>
Sat, 15 Oct 2011 00:57:35 +0000 (17:57 -0700)
The lack of dex file made the Ant package task throw an NPE.

Also some minor typo fix.

Change-Id: Ic617ee66017c402f211f5400baf5a00eb7e6cff5

anttasks/src/com/android/ant/ApkBuilderTask.java
anttasks/src/com/android/ant/BuildTypedTask.java
anttasks/src/com/android/ant/InputPath.java
files/ant/build.xml

index 1cf1c0d..5b3654f 100644 (file)
@@ -233,7 +233,9 @@ public class ApkBuilderTask extends SingleDependencyTask {
             inputPaths.add(resourceInputPath);
 
             // dex file
-            inputPaths.add(new InputPath(dexFile));
+            if (dexFile != null) {
+                inputPaths.add(new InputPath(dexFile));
+            }
 
             // zip input files
             List<File> zipFiles = new ArrayList<File>();
index c697bac..3f4b64a 100644 (file)
@@ -41,7 +41,7 @@ public abstract class BuildTypedTask extends Task {
     }
 
     /**
-     * Returns if it is a new build. If the built type is not input
+     * Returns if it is a new build. If the build type is not input
      * from the XML, this always returns true.
      * A build type is defined by having an empty previousBuildType.
      */
index b1a98b5..905e7bc 100644 (file)
@@ -34,6 +34,9 @@ public class InputPath {
     }
 
     public InputPath(File file, Set<String> extensionsToCheck) {
+        if (file == null) {
+            throw new RuntimeException("File in InputPath(File) can't be null");
+        }
         mFile = file;
         mTouchedExtensions = extensionsToCheck;
     }
index 57effb2..16ae6a1 100644 (file)
@@ -24,7 +24,7 @@
     -->
 
     <!-- ******************************************************* -->
-    <!-- *************** Overrideable Properties *************** -->
+    <!-- **************** Overridable Properties *************** -->
     <!-- ******************************************************* -->
 
     <!-- You can override these values in your build.xml or build.properties.