Skip to content

Android Development Environment Configuration in Mac OS X

9miao edited this page Sep 4, 2014 · 1 revision

Android Development Environment Configuration in Mac OS X

Environment configuration in Mac is a relatively easy job since Mac system integrates Java and Python environment, so we do not need to configure java and python.

1.Download NDK and ADT

Please download a relatively new version NDK and latest version ADT and unzip to appointed directory
NDK download address: http://developer.android.com/tools/sdk/ndk/index.html
ADT download address: http://developer.android.com/sdk/index.html

2..bash_profile file Configuration

Open terminal and type ‘pico .bash_profile’, then open the text editor of this file and type the below text:

1

2

3

4

5

6

export CROSSAPP_ROOT=/Users/jie/Documents/CrossApp

export ANDROID_SDK_ROOT=/Users/jie/Documents/android/adt-bundle-mac/sdk

export ANDROID_NDK_ROOT=/Users/jie/Documents/android/android-ndk-r8b

export NDK_ROOT=/Users/jie/Documents/android/android-ndk-r8b

export PATH=$PATH:$ANDROID_NDK_ROOT

export PATH=$PATH:$ANDROID_SDK_ROOT

Modify all variables’ path into your own tool package’s path, we can use export command to see our just configured variables. If system doesn’t list our just configured variables, it means that the modification on .bash_profile file is invalid, so after the modification we need run source .bash_profile command again to enable it take effect immediately.

3.Build CrossApp Project

Open terminal and build project by following the below commands.

1

2

3

4

cd $CROSSAPP_ROOT

cd tools

cd project-creator

./create_project.py

System will list a sample to show us how to build project via the above commands. Then we build a project according to this sample, such as:

1

./create_project.py –project MyFirstApp –package com.crossapp.test –language cpp

The reminder ‘Have fun’ means project have been successfully built, we can find this project in projects directory of CrossApp. Note: do not directly copy the above command into terminal on account of system might reports format error, and we suggest you manually type the command.

4.Importing Eclipse

Open eclipse, File->Other->Android->Android Project from Existing Code, click Browse, and select proj.android and import android project into eclipse.

After we imported project into eclipse, firstly we need to copy the folders in CrossApp/CrossApp/platform/android/java/src path into project /proj.android/src.

Secondly right click project ->Properties->C/C++ Build->Environment, and click ‘Add’ on the right side to add a variable whose name is NKD_ROOT and value is NDK’s root directory.

When we finished the above steps, we can directly click project ->Run As Android Application and start to compile our project.

Note: the above steps are only valid for creating project in Mac, if you want to debug compiled CrossApp project of Windows in Mac, you need to change Build command in C/C++ Build into bash ${ProjDirPath}/build_native.sh as well as delete import-add-path relative paths in jni/Android.mk that was additionally added in Windows. Please view the steps after importing eclipse in different environments if you want to know the distinction between android development environment configuration in Mac and Windows.

So far, our Android basic environment setting up job is done!

Clone this wiki locally