Doc:2.6/Manual/Game Engine/Android/Building Blender for Android

提供: wiki
移動先: 案内検索

Building Blender for Android

Structure

Because Android uses Java primarily, Blender building is much harder and requires multiple steps.

  • Build Android App
  • Build Blender
    • This will use Android App to run makesdna and makesrna and copy results back
  • Two options
    • Push libs and executable with a script to Android App
    • Create installfile.zip and recompile Android App so it can be easily used for distribution
      • Sign for release

Preparation

Currently Android can be build on linux and probably on Mac (isn't tested). There won't be Windows support in near future because we should use gcc-like compile, and it will be troublesome to support Windows environment (paths, scripts). Also, you have to have real Android 2.2 or higher device, in order to compile and test Blender as emulator doesn't support OpenGL ES 2.0. Beware that Android port is a work in progress: a. There is no graphic output yet. b. Build system might be broken, but I will try to make sure that it is compilable every Friday

Installing Android SDK and JDK

  • Use this to install Eclipse (or JDK 6, Apache Ant) and then Android SDK
  • Everything except SDK can be downloaded through distro's repository
  • http://developer.android.com/sdk/installing.html
  • You need :"apt-get install ia32-libs" if linux is x64
  • Add following paths to PATH
<<Path to Android SDK>>/android-sdk-linux/tools/
<<Path to Android SDK>>/android-sdk-linux/platform-tools/
  • Run "android" command from <<Path to Android SDK>>/android-sdk-linux/tools/
    • Install SDK 13
    • SDK 10
  • To test if it is succesfully set up, run
adb devices

Installing Android NDK

Install NDK (I recommend r7b or r8 version, because it is what I use and with which all libs are compiled and r8a fails on some devices)

Also add it to PATH

<<Path to Android NDK>>/android-ndk-r7b
  • Now create standalong toolchain
    • Remember its path
<<Path to Android NDK>>/android-ndk-r7b/build/tools/make-standalone-toolchain.sh --platform=android-9 --install-dir=/__absolute_path__/androidtc
  • For lib compilations I used android-9

Making First Android App

Go to

source/android/app

Connect your device. And then in terminal run

./deploy.sh

This script should compile small C and Java source. Created app will be send to device.

Now, restart the device to avoid problems in next step.

Compiling Blender

Create a folder on the same level as soc-2012-swiss_cheese and lib. For example "abuild"

mkdir abuild
cd abuild

Generate Cmake file in build folder

 cmake -DCMAKE_TOOLCHAIN_FILE=../soc-2012-swiss_cheese/build_files/cmake/config/blender_android.cmake  ../soc-2012-swiss_cheese -DTOOLCHAIN_PATH=/<<your_toolchain_path>>

now run make

make

Now you have libblenderplayer.so inside abuild/lib

Deploying to Device

Method I

This is method is used for deployment

Create internalfiles.zip for Android App

It must contain:

  • libblenderplayer.so
  • libfreetype.so.6
  • libGLarm.so
  • libGLUarm.so
  • libjpeg.so.8
  • libpng15.so.15
  • libpython3.2m.so.1.0
  • libz.so.1
  • python
    • include
    • lib
    • scripts

Here is template without libblenderplayer.so http://download.blender.org/ftp/incoming/android_template_08_20_12_internalfiles.zip. Add freshly compiled libblenderplayer.so and place as source/app/assets/internalfiles.zip

Caution, libblenderplayer.so, libfreetype.so.6 etc must me in root dir inside internalfiles.zip

Recompile Android App

./deploy.sh

internalfiles.zip is unzipped by Android App during first start up to insternal directory (/data/data/org.blender.play/). If you have rooted device, you can

adb shell
cd /data/data/org.blender.play/
ls

To see internal files

Method II

This is method for fast updating some files. Internal app file structure corresponds to internalfiles.zip You can directly "adb push" files from desktop to /data/data/org.blender.play/ if you device is root. Or you can use

adb push desktop.file /sdcard/temp.file
adb shell am start -n porg.blender.play/.CoyIntern --es from /sdcard/temp.file  --es to device.file

Notes

If something failed, irc me. Probably I already had that problem and forgot to mention here. ndk-gdb is very poor because it goes through all java hoops and don't have a source and good backtrace. The build system is not optimized. You can improve performance by adding C flags inside cmake:

-march=armv7-a -mfloat-abi=softfp -mthumb