User Tools

Site Tools


proton:android_setup

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
proton:android_setup [2012/05/23 13:34]
seth
proton:android_setup [2017/05/22 08:33] (current)
seth
Line 1: Line 1:
 +Before going in to compilation details check [[proton:​android_projects|what you need to know about the Android projects in general]].
 +
 ====Compiling for Android from Windows==== ====Compiling for Android from Windows====
-**NEW:​** ​ 3/12/2012 - Proton no longer requires Cygwin to be install to compile android apps on Windows! 
  
-**NEW:**  5/23/2012 - Samples now work with latest ​versions of Android SDK (**YOU MUST HAVE THE LATEST SDK TOOLS NOW!**) , NDK and Antand use new build setup with java pre-processing step+** NOTE: ** 5/22/2017:  I updated to the latest ​NDK (r14b 64bit) and it works fine, C++11 now supported 
 + 
 +**NOTE:**  ​6/​19/​2013 - Proton has been updated to work with the latest Android platform tools (17), SDK tools (22.0.1) ​and the latest NDK. (r8e)  If your old proton project won't compilesteal the android/build.xml from proton example and replace your old one.  (And edit the top as need..)
  
 Originally the Android platform was crippled by requiring all "​app"​ code to be written in Java. Originally the Android platform was crippled by requiring all "​app"​ code to be written in Java.
Line 20: Line 23:
 The C++ "​glue"​ code for Android is located in /​shared/​android and the .Java parts are in /​shared/​android/​src. ​ These are shared between all applications so be careful if you touch them. The C++ "​glue"​ code for Android is located in /​shared/​android and the .Java parts are in /​shared/​android/​src. ​ These are shared between all applications so be careful if you touch them.
  
-** Side Note **: There is actually an even newer way to do NDK now - something called a NativeActivity where you can use 100% C++.  Except you can't, because things like IAP and Tapjoy integration would still be in Java so I assume more ugly bridging would be required.. also it requires Android 2.3+ (boo, hiss), but I plan to do an android target supporting this eventually, especially since it seems to be the only way to fully support the xperia play gamepad controls. -Seth+** Side Note **: There is actually an even newer way to do NDK now - something called a NativeActivity where you can use 100% C++.  Except you can't, because things like IAP and Tapjoy integration would still be in Java so I assume more ugly bridging would be required.. also it requires Android 2.3+, but I plan to do an android target supporting this eventually, especially since it seems to be the only way to fully support the xperia play analog sticks. -Seth
  
 ====Prerequisites==== ====Prerequisites====
Line 35: Line 38:
 Important note:  For all this stuff, try to choose a custom install path WITHOUT spaces in it.  There, I just saved you like 40 minutes of diagnosing vague errors that will happen later. ​ No charge, friend! Important note:  For all this stuff, try to choose a custom install path WITHOUT spaces in it.  There, I just saved you like 40 minutes of diagnosing vague errors that will happen later. ​ No charge, friend!
  
-  * Install the [[http://​developer.android.com/​sdk/​index.html|Android SDK]] - use the Windows exe version so it will also prompt you to install the Java SE JDK which will be needed as well. +  * Install the [[http://​developer.android.com/​sdk/​index.html|Android SDK]] - use the Windows exe version so it will also prompt you to install the Java SE JDK which will be needed as well. NOTE - you'll need to install the 32bit version of the Java JDK, NOT the 64 bit, since the android SDK install process won't recognize the 64 bit version. Also note, the advice about using a custom install path applies as much for the Java JDK as it does for everything else. If you install Java to Program Files, ANT will complain about this later (since Ant sits on top of Java)
-  * Add **C:​\whatever\android-sdk\platform-tools** to your windows path ( +  * Add **C:​\whatever\android-sdk\platform-tools** to your windows path  
-  * Add **C:​\whatever\Android\android-sdk\tools** to your windows path+  * Add **C:​\whatever\android-sdk\tools** to your windows path
  
 If you type "​android"​ from the DOS prompt it will bring up the Android SDK and AVD Manager. ​ This is where you create AVDs (basically, emulator profiles, if you want to use the emulator) and can install optional libraries. ​ It also shows you when you can update your platform tools. If you type "​android"​ from the DOS prompt it will bring up the Android SDK and AVD Manager. ​ This is where you create AVDs (basically, emulator profiles, if you want to use the emulator) and can install optional libraries. ​ It also shows you when you can update your platform tools.
Line 66: Line 69:
   * In Settings->​Applications->​Development enable "USB debugging"​   * In Settings->​Applications->​Development enable "USB debugging"​
   * After plugging in your phone, in the Win device manager it will probably say "no drivers installed"​ - click update driver and install them   * After plugging in your phone, in the Win device manager it will probably say "no drivers installed"​ - click update driver and install them
-  * Typing "abd devices"​ should show your plugged in phone as a device now.  If so, congrats, you got this far!+  * Typing "adb devices"​ should show your plugged in phone as a device now.  If so, congrats, you got this far!
  
  
Line 82: Line 85:
  
   * Install [[http://​ant.apache.org/​bindownload.cgi|Ant]],​ grab the latest .zip (v1.8.3 at this time) and unzip it to somewhere.   * Install [[http://​ant.apache.org/​bindownload.cgi|Ant]],​ grab the latest .zip (v1.8.3 at this time) and unzip it to somewhere.
-  * Add the ant directory to your windows path.  Verify it's working by typing "​ant"​ in a dos prompt, it should do something other than "bad command or file error"​.+  * Add the ant directory to your windows path.  Verify it's working by typing "​ant"​ in a dos prompt, it should do something other than "bad command or file error"​. ​NOTE - the path you add needs to go to the Binaries directory, not just the root ant dir - E.g. C:​\Android\apache-ant-1.8.4\bin
   * Download the [[http://​developer.android.com/​sdk/​ndk/​index.html|Android NDK]] and unzip it somewhere. ​ Again, put it somewhere with no spaces in the filenames if possible. ​ (Not "​Program Files"​!)   * Download the [[http://​developer.android.com/​sdk/​ndk/​index.html|Android NDK]] and unzip it somewhere. ​ Again, put it somewhere with no spaces in the filenames if possible. ​ (Not "​Program Files"​!)
   * Make sure that the environmental variable ANT_HOME exists and is set to your ant path.  (ie, c:\pro\ant)   * Make sure that the environmental variable ANT_HOME exists and is set to your ant path.  (ie, c:\pro\ant)
Line 148: Line 151:
   * Want to clone one of the example apps to be the starting place of a new app? Then read the tutorial on [[:​proton_vsrename|how to create a new project by copying from a Proton sample app]].   * Want to clone one of the example apps to be the starting place of a new app? Then read the tutorial on [[:​proton_vsrename|how to create a new project by copying from a Proton sample app]].
   * Want to compile faster? ​ Change call ndk-build in build_prepare.bat to call ndk-build -j8 (or lower than eight if you don't have 8 threads on your multicore cpu)   * Want to compile faster? ​ Change call ndk-build in build_prepare.bat to call ndk-build -j8 (or lower than eight if you don't have 8 threads on your multicore cpu)
- 
-====V2 Android setup==== 
-If you look at android/​build_prepare.bat you'll see a lot is going on.  It's actually taking a bunch of android files from /​shared/​android/​v2_src and running a preprocessor step on them using ant. (JavaPP (javapp.jar) is copied to your ant dir) 
- 
-The preprocessor allows #define and #ifdef stuff to work in java, and also replaces the package name with your own.  It also runs on AndroidApp.cpp and modifies the JNI bindings to match the package name. 
- 
-When you're done building, you can see what it changed by looking in the temp directories android/​temp_final_cpp_src,​ andriod/​temp_final_src. 
- 
-build_prepare.bat also also where it copies any required 3rd party sources/​libraries into the app's libs directory, such as Google'​s billing stuff, Tapjoy or Hooked. ​ (No preprocessor is run on those) 
- 
-Most examples use the new V2 android setup, but a few older ones don'​t. ​ (RTPhysics?​) ​ The old method didn't have the preprocess step which created problems later when enabling IAP and such or including/​removing libraries on the java side flexibly. 
proton/android_setup.1337780079.txt.gz · Last modified: 2012/05/23 13:34 by seth