OSDN Git Service

Fix NPE in projects with no code. Do not merge.
authorXavier Ducrohet <xav@android.com>
Sat, 15 Oct 2011 00:23:43 +0000 (17:23 -0700)
committerXavier Ducrohet <xav@android.com>
Sat, 15 Oct 2011 00:55:25 +0000 (17:55 -0700)
The lack of dex file made the ant package task throw
an NPE.

Change-Id: Id3de0deb4ec1d6a90f0474ea09d43ddde9cbe97f

anttasks/src/com/android/ant/ApkBuilderTask.java
anttasks/src/com/android/ant/InputPath.java

index 88bd59c..57347a4 100644 (file)
@@ -233,7 +233,9 @@ public class ApkBuilderTask extends BaseTask {
             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 3327385..f607c2e 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;
     }