AI開發實戰1-App Inventor的編譯
1 App Inventor的編譯
Youwill need a full Java JDK (6 or 7, preferably from Oracle; JRE is not enough)and Python to compile and run the servers.
需要在電腦上安裝JDK6或7,才能正常編譯。
但ant的不同版本需要的JDK不同,像1.10.1版本就需要JDK8,否則編譯的時候,會報如下錯誤:
Exception in thread "main"java.lang.UnsupportedClassVersionError: org/apache/tools/ant/launch/Launcher :Unsupported major.minor version 52.0
編譯的時候,直接輸入ant命令,會編譯所有原始碼,花費時間較長,在本人電腦上是6分鐘多。實際往往不需要編譯全部程式碼,只編譯改動的模組就可以了。
在原始碼的appinventor資料夾下有個build.xml檔案,在其中有許多target標籤:
<target name="all">
<ant inheritAll="false" useNativeBasedir="true"dir="appengine"/>
<ant inheritAll="false" useNativeBasedir="true"dir="blocklyeditor"/>
<ant inheritAll="false" useNativeBasedir="true"dir="common"/>
<ant inheritAll="false" useNativeBasedir="true"dir="buildserver"/>
<ant inheritAll="false" useNativeBasedir="true"dir="components"/>
<ant inheritAll="false" useNativeBasedir="true"dir="buildserver" target="PlayApp"/>
</target>
…
<target name="MakeAuthKey">
…
<target name="comps">
…
<target name="extensions">
…
<target name="clean">
<ant inheritAll="false" useNativeBasedir="true"dir="appengine" target="clean"/>
<ant inheritAll="false"useNativeBasedir="true" dir="blocklyeditor"target="clean"/>
<ant inheritAll="false" useNativeBasedir="true"dir="aimerger" target="clean"/>
<ant inheritAll="false" useNativeBasedir="true"dir="buildserver" target="clean"/>
<ant inheritAll="false" useNativeBasedir="true"dir="common" target="clean"/>
<ant inheritAll="false" useNativeBasedir="true"dir="components" target="clean"/>
<delete dir="build"/>
<delete dir="reports"/>
</target>
每個target標籤中間說明了使用ant + target name時,編譯的模組,如輸入如下命令:
ant all——編譯所有模組,等同於只輸入ant
antextensions——編譯外掛
antMakeAuthKey——編譯AuthKey
還有個特殊的編譯命令:
antclean——刪除之前編譯生成的build和reports資料夾。