App Inventor2項目部署到本地


介紹App Inventor

  App Inventor 原是Google實驗室(Google Lab)的一個子計划,該項目是一個完全在線開發的Android編程環境,拋棄復雜的程式代碼而使用積木式的堆疊法來完成的Android程式。App Inventor

  2012年1月1日移交給麻省理工學院行動學習中心,並已於3月4日公布使用。【前面都是我從網上找的介紹,詳細情況可以自行上網了解

  本文主要是介紹我部署到本地的詳細經過。參考的書籍:《App Invenrot2 定制與二次開發》強增編著。

----------------------------------------------------------------------------------------------------------------------------------

1. 本地環境的准備

  首先需要准備本地環境,官方的文檔是這么給出的:

 

  我的JDK用的是:java version "1.7.0_79",因為文檔中推薦使用JDK6或者7。ant的版本使用的是: version 1.9.4。JDK和ANT都需要配置環境變量。

JAVA_HOME 本地JDK的安裝路徑
Path %JAVA_HOME%\bin;%JAVA_HOME%\jre\bin;
CLASSPATH  .;%JAVA_HOME%\lib;%JAVA_HOME%\lib\tools.jar
ANT_HOME ant的安裝路徑
PATH ;%ANT_HOME%\bin

 

  值得一提的是安裝完git后,也需要添加環境變量(我第一次就是因為沒有配置環境變量,反復出錯……)。

  最后,需要下載AppEngine SDK ( https://developers.google.com/appengine/downloads ) ,官網上推薦使用1.9.27及其以下版本:
        a. The current supported version for MIT App Inventor is 1.9.27.

            http://central.maven.org/maven2/com/google/appengine/appengine-java-sdk/1.9.27/

  同樣,下載完后,最好配置環境變量:在Path下面添加:****實際本地的路徑***\appengine-java-sdk-1.9.27\bin目錄的路徑。

2.  獲取源碼

  前面的步驟,你已經在計算機本地安裝了git,然后找個合適的位置,新建文件夾存放代碼,在文件夾中鼠標右鍵,選擇Git Bash Here,使用 git init初始化當前目錄。

  然后,輸入命令:git clone https://github.com/mit-cml/appinventor-sources.git ,獲取源代碼。需要等待一段時間……官網文檔(This will create a folder named “appinventor-sources” where the sources (and a copy of the repository) will reside. )就是說在當前文件下會生成一個“appinventor-sources” 的文件夾。文檔中還有這么一段話,我不清楚是什么意思,只是照着做了(We’ll refer to this folder (即“appinventor-sources” 的文件夾)throughout the rest of these instructions as the appinventor parent folder.  The appinventor  parent folder also contains a file called sample-.gitignore. This file should be copied to another file simply named .gitignore which will keep generated files from being added to the git  index .)

  

  就是將sample-.gitignore文件復制了一份,重命名為.gitignore。(在winodws系統下,這樣可能有點困難,所以我借助git命令窗口來完成的,touch .gitignore,然后將內容拷貝進去。)緊接着,

  Checking out Blockly as a dependency is also needed, and can be done by issuing the following command (from the appinventor-sources folder),官網的意思是進入appinventor-sources

  文件夾執行命令:git submodule update --init,這和我參考書上的不一樣,還是按照官方文檔來。上面的步驟完成后,源代碼就獲取到了,為了謹慎期間,在編譯之前,我還是備份了一下。

3. 編譯項目

  進入項目的根目錄:***\appinventor-sources\appinventor

  如果不是第一次編譯的話可以使用ant clean命令,會清理掉一些垃圾文件,但是要謹慎使用!!因為一些項目也會清理掉。(附上文檔:Cleaning isn’t necessary every time you build, but it’s a good idea to clean each time before   you build  in case some junk has crept into the various build directories. Note again that if you clean, all your projects will go away, so make sure you have copies of the projects before cleaning. )

  在編譯項目之前使用命令ant MakeAuthKey,來生成key。僅需執行一次。

  然后使用命令ant來編譯項目。

  Building should take several minutes and end with the message BUILD SUCCESSFUL. 看到BUILD SUCCESSFUL,就說明編譯成功了。

4. 啟動服務,訪問網站

   NOTE: As of 4/18/2016 you must use a version of the App Engine SDK that is at 1.9.27 or lower. The dev_appserver in newer versions will not work. You will also want to have the latest version and use that for deployment to App Engine itself.這個前面也提到了,就用1.9.27的版本就好了,我就是用這個運行成功的。

  appinventor文件夾下面,使用命令:<your appengine SDK folder>/appengine-java-sdk-1.9.11/bin/dev_appserver.cmd --port=8888 --address=0.0.0.0 appengine/build/war/(前面配置環境變量的話,只需要運行加粗的部分的命令即可。)

  

  首次編譯這個項目要花費一點時間,耐心等待。出現下面的情況,說明成功:

  然后,進入/appinventor/buildserver目錄下,運行命令:

  ant RunLocalBuildServer

  成功后,如圖:

  

  在瀏覽器訪問localhost:8888,可以看到登錄頁面,點擊:

  

  接着點擊Login,接着單擊“I accept the terms of service”按鈕就可以進入開發環境。

  

  待續……

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM