2010-02-11 102 views
1

使用螞蟻構建android應用程序時,我得到以下異常。 無法弄清楚爲什麼會拋出這些異常!在使用螞蟻構建android應用程序時產生NullPointerException

Execute:Java13CommandLauncher: Executing 'D:\Android-2.0\android-sdk-windows\platforms\android-1.5\tools\aapt.exe' with arguments: 
'package' 
'-f' 
'-M' 
'E:\manish_test\timetrack\client\static\android\AndroidManifest.xml' 
'-S' 
'E:\manish_test\timetrack\client\static\android\res' 
'-A' 
'E:\manish_test\timetrack\client\static\android\assets' 
'-I' 
'D:\Android-2.0\android-sdk-windows\platforms\android-1.5\android.jar' 
'-F' 
'C:\CLIENT_BUILDS\QA\3.0.9\Android\11-Feb-2010_b1\XoraTimeTrack.ap_' 

周圍可執行文件和參數的'字符是 不是命令的一部分。

 [null]  (skipping index file 'E:\manish_test\timetrack\client\static\android\res\drawable\Thumbs.db') 
Class org.apache.tools.ant.Project loaded from parent loader (parentFirst) 
Finding class com.android.sdklib.internal.project.ProjectProperties$PropertyType 
Loaded from D:\Android-2.0\android-sdk-windows\tools\lib\sdklib.jar com/android/sdklib/internal/project/ProjectProperties$PropertyType.class 
Class java.lang.Enum loaded from parent loader (parentFirst) 
Class com.android.sdklib.internal.project.ProjectProperties$PropertyType loaded from ant loader (parentFirst) 
Finding class com.android.sdklib.internal.project.ProjectProperties 
Loaded from D:\Android-2.0\android-sdk-windows\tools\lib\sdklib.jar com/android/sdklib/internal/project/ProjectProperties.class 
Class com.android.sdklib.internal.project.ProjectProperties loaded from ant loader (parentFirst) 
Class java.util.Map loaded from parent loader (parentFirst) 
Class java.io.OutputStream loaded from parent loader (parentFirst) 
Class java.io.FileOutputStream loaded from parent loader (parentFirst) 
Class java.lang.Throwable loaded from parent loader (parentFirst) 
Class java.lang.AssertionError loaded from parent loader (parentFirst) 
Class java.lang.Class loaded from parent loader (parentFirst) 
Class java.util.HashMap loaded from parent loader (parentFirst) 
Finding class com.android.sdklib.internal.project.ApkConfigurationHelper 
Loaded from D:\Android-2.0\android-sdk-windows\tools\lib\sdklib.jar com/android/sdklib/internal/project/ApkConfigurationHelper.class 
Class com.android.sdklib.internal.project.ApkConfigurationHelper loaded from ant loader (parentFirst) 
Finding class com.android.sdklib.internal.project.ApkSettings 
Loaded from D:\Android-2.0\android-sdk-windows\tools\lib\sdklib.jar com/android/sdklib/internal/project/ApkSettings.class 
Class com.android.sdklib.internal.project.ApkSettings loaded from ant loader (parentFirst) 
    [antcall] Exiting E:\manish_test\timetrack\build\build-Android-1.0.xml. 

BUILD FAILED 
E:\manish_test\timetrack\build\build-Android-1.0.xml:371: The following error occurred while executing this line: 
E:\manish_test\timetrack\build\build-Android-1.0.xml:302: java.lang.NullPointerException 
    at org.apache.tools.ant.ProjectHelper.addLocationToBuildException(ProjectHelper.java:508) 
    at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:418) 
    at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:105) 
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288) 
    at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
    at java.lang.reflect.Method.invoke(Method.java:597) 
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) 
    at org.apache.tools.ant.Task.perform(Task.java:348) 
    at org.apache.tools.ant.Target.execute(Target.java:357) 
    at org.apache.tools.ant.Target.performTasks(Target.java:385) 
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337) 
    at org.apache.tools.ant.Project.executeTarget(Project.java:1306) 
    at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41) 
    at org.apache.tools.ant.Project.executeTargets(Project.java:1189) 
    at org.apache.tools.ant.Main.runBuild(Main.java:758) 
    at org.apache.tools.ant.Main.startAnt(Main.java:217) 
    at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257) 
    at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104) 
Caused by: E:\manish_test\timetrack\build\build-Android-1.0.xml:302: java.lang.NullPointerException 
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:116) 
    at org.apache.tools.ant.Task.perform(Task.java:348) 
    at org.apache.tools.ant.Target.execute(Target.java:357) 
    at org.apache.tools.ant.Target.performTasks(Target.java:385) 
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337) 
    at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:38) 
    at org.apache.tools.ant.Project.executeTargets(Project.java:1189) 
    at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:416) 
    ... 17 more 
Caused by: java.lang.NullPointerException 
    at com.android.sdklib.internal.project.ApkConfigurationHelper.getSettings(ApkConfigurationHelper.java:31) 
    at com.android.ant.AaptExecLoopTask.execute(AaptExecLoopTask.java:137) 
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288) 
    at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
    at java.lang.reflect.Method.invoke(Method.java:597) 
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) 
    ... 24 more 
--- Nested Exception --- 
E:\manish_test\timetrack\build\build-Android-1.0.xml:302: java.lang.NullPointerException 
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:116) 
    at org.apache.tools.ant.Task.perform(Task.java:348) 
    at org.apache.tools.ant.Target.execute(Target.java:357) 
    at org.apache.tools.ant.Target.performTasks(Target.java:385) 
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337) 
    at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:38) 
    at org.apache.tools.ant.Project.executeTargets(Project.java:1189) 
    at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:416) 
    at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:105) 
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288) 
    at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
    at java.lang.reflect.Method.invoke(Method.java:597) 
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) 
    at org.apache.tools.ant.Task.perform(Task.java:348) 
    at org.apache.tools.ant.Target.execute(Target.java:357) 
    at org.apache.tools.ant.Target.performTasks(Target.java:385) 
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337) 
    at org.apache.tools.ant.Project.executeTarget(Project.java:1306) 
    at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41) 
    at org.apache.tools.ant.Project.executeTargets(Project.java:1189) 
    at org.apache.tools.ant.Main.runBuild(Main.java:758) 
    at org.apache.tools.ant.Main.startAnt(Main.java:217) 
    at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257) 
    at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104) 
Caused by: java.lang.NullPointerException 
    at com.android.sdklib.internal.project.ApkConfigurationHelper.getSettings(ApkConfigurationHelper.java:31) 
    at com.android.ant.AaptExecLoopTask.execute(AaptExecLoopTask.java:137) 
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288) 
    at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
    at java.lang.reflect.Method.invoke(Method.java:597) 
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) 
    ... 24 more 
--- Nested Exception --- 
java.lang.NullPointerException 
    at com.android.sdklib.internal.project.ApkConfigurationHelper.getSettings(ApkConfigurationHelper.java:31) 
    at com.android.ant.AaptExecLoopTask.execute(AaptExecLoopTask.java:137) 
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288) 
    at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
    at java.lang.reflect.Method.invoke(Method.java:597) 
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) 
    at org.apache.tools.ant.Task.perform(Task.java:348) 
    at org.apache.tools.ant.Target.execute(Target.java:357) 
    at org.apache.tools.ant.Target.performTasks(Target.java:385) 
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337) 
    at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:38) 
    at org.apache.tools.ant.Project.executeTargets(Project.java:1189) 
    at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:416) 
    at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:105) 
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288) 
    at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
    at java.lang.reflect.Method.invoke(Method.java:597) 
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) 
    at org.apache.tools.ant.Task.perform(Task.java:348) 
    at org.apache.tools.ant.Target.execute(Target.java:357) 
    at org.apache.tools.ant.Target.performTasks(Target.java:385) 
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337) 
    at org.apache.tools.ant.Project.executeTarget(Project.java:1306) 
    at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41) 
    at org.apache.tools.ant.Project.executeTargets(Project.java:1189) 
    at org.apache.tools.ant.Main.runBuild(Main.java:758) 
    at org.apache.tools.ant.Main.startAnt(Main.java:217) 
    at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257) 
    at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104) 

回答

0

發現解決方案異常是由於屬性文件名和位置的硬編碼而引發的。 ApkConfigurationHelper需要ant項目基礎目錄中的default.properties文件,並且應在此文件中設置屬性split.density。 它現在像一個魅力工作。

感謝所有爲你所有的幫助..

- 馬尼什

0

最後:

Caused by: java.lang.NullPointerException 
    at com.android.sdklib.internal.project.ApkConfigurationHelper.getSettings(ApkConfigurationHelper.java:31) 

是這裏最重要的一個。
你需要檢查ApkConfigurationHelper源代碼,看看它爲什麼會在這裏拋出一個NPE。

+0

第31行是這個 布爾splitByDensity = Boolean.parseBoolean(properties.getProperty( ProjectProperties.PROPERTY_SPLIT_BY_DENSITY)); 我很無知在哪裏設置此屬性。 – Manish 2010-02-11 09:05:08

+0

嘗試設置在屬性這個屬性文件,但仍然得到同樣的錯誤 – Manish 2010-02-11 09:52:50

+0

@Manish:也許'properties'實際上是空...意爲'PROPERTY_SPLIT_BY_DENSITY'是不是一個問題,但它的容器('properties')未能正確初始化。 – VonC 2010-02-11 12:27:40