title: Compiling Android project from terminal
body: <p>I'm experimenting with android terminal emulator(<a href="https://market.android.com/details?id=com.spartacusrex.spartacuside" rel="nofollow">Terminal IDE</a>) and trying to compile an Android project. I use the following script to compile.</p>
  
  <pre><code>#Build script
  
  #cd into the home dir - this way it works when run from inside vim or any other folder
  cd ~/projects/simple_search/
  
  #Clean up
  rm -rf build
  rm -rf dist
  
  #create the needed directories
  mkdir -m 770 -p dist
  mkdir -m 770 -p build/classes
  
  #Rmove the R.java file as will be created by aapt
  rm src/com/simple/search/R.java 
  
  #Now use aapt
  echo Create the R.java file
  aapt p -f -v -M AndroidManifest.xml -F ./build/resources.res -I ~/system/classes/android.jar -S res/ -J src/com/simple/search
  
  #cd into the src dir
  cd src
  
  #Now compile - note the use of a seperate lib (in non-dex format!)
  echo Compile the java code
  javac -verbose -cp ../libs/demolib.jar -d ../build/classes \
  com/simple/search/AboutDialog.java \
  com/simple/search/CustomWindow.java \
  com/simple/search/DatabaseHelper.java \
  com/simple/search/SearchResults.java \
  com/simple/search/SimpleSearch.java \
  com/simple/search/SuggestionProvider.java \
  com/simple/search/Tag.java \
  com/simple/search/TestAction.java \
  com/simple/search/TestDetails.java
  
  #Back out
  cd ..
  
  #Now into build dir
  cd build/classes/
  
  #Now convert to dex format (need --no-strict) (Notice demolib.jar at the end - non-dex format)
  echo Now convert to dex format
  dx --dex --verbose --no-strict --output=../simple_search.dex org ../../libs/demolib.jar
  
  #Back out
  cd ../..
  
  #And finally - create the .apk
  apkbuilder ./dist/simple_search.apk -v -u -z ./build/resources.res -f ./build/simple_search.dex 
  
  #And now sign it
  cd dist
  signer simple_search.apk simple_search_signed.apk
  
  cd ..
  </code></pre>
  
  <p>The script executes fine till <code>cd build/classes/</code>. But at <code>dx --dex --verbose --no-strict --output=../simple_search.dex org ../../libs/demolib.jar</code> I'm encountering the following error.</p>
  
  <pre><code>Now convert to dex format
  
  UNEXPECTED TOP-LEVEL EXCEPTION:
  java.lang.RuntimeException: org: file not found
          at com.android.dx.util.FileUtils.readFile(FileUtils.java:55)
          at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:139)
          at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:113)
          at com.android.dx.command.dexer.Main.processOne(Main.java:247)
          at com.android.dx.command.dexer.Main.processAllFiles(Main.java:183)
          at com.android.dx.command.dexer.Main.run(Main.java:139)
          at com.android.dx.command.dexer.Main.main(Main.java:120)
          at com.android.dx.command.Main.main(Main.java:89)
          at com.spartacusrex.spartacuside.external.dx.main(dx.java:14)
          at dalvik.system.NativeStart.main(Native Method)
  processing archive ../../libs/demolib.jar...
  ignored resource META-INF/MANIFEST.MF
  processing org/library/libfunc.class...
  1 error; aborting
  </code></pre>
  
  <p>What is wrong with the script? Can you point me in the right direction? Any smallest help is appreciated.</p>