воскресенье, 29 мая 2011 г.

How to: Configure Enviroment for Native (Windows)

Полезная ссылка тут: http://www.pocketmagic.net/?p=1332

Для истории её содержимое  копирую сюда:


Introduction


Since most of the NDK tools are coming from the Linux environment, that OS was my first approach in building native C applications for Android. See this tutorial for a start.
However, I also needed to be able to compile JNI Android apps using the Windows environment. It proved an easy task, but there were some issues, so I decided to write this guide.

Install Android NDK on Windows and use it to compile a JAVA/JNI application

You will need an internet connection to install Cygwin and the Android SDK automatically from the Internet.

  • 1) Download the Android NDK for Windows



  • Download link.
    Current version of the file is: android-ndk-r4b-windows.zip 45MB

  • 2) Download Cygwin



  • Download link. (Direct Link)
    Select the mirror you need to download from then follow the installation guide.
    On package selection, Open Devel category and check "make":
    2.1
    I've installed it to C:\cygwin

  • 3) Download the latest Android SDK for Windows



  • Download link.
    Current version is android-sdk_r06-windows.zip 23MB

  • 4) Install the SDK



  • 4.1) Unzip the zip content to a location on your harddisk. I choose:
    D:\work_code\android\android-sdk-windows\
    You will find SDK Setup.exe . Run it. I get a warning to install JAVA JDK
    4.2) Download Java JDK
    Download link.
    Select platform "Windows". Current file is: jdk-6u21-windows-i586.exe (Direct link)
    4.3) Install the Java JDK: simply run the exe . It takes a few minutes to complete.
    4.4) Re-run the SDK Setup.exe from the Android SDK.
    This opens the Android SDK and AVD Manager. If you get a HTTPS Error:
    4.5.1
    go to Settings and check the "Force https:// ..." checkbox:
    4.5.2
    4.5) Go to Available Packages, select all, and press Install Selected:
    4.6
    The installer will download the packages from the internet, and might prompt you to accept terms, which you must do if you want to continue with the installation. This step takes a few minutes.

  • 5) Install the NDK



  • 5.1) Unzip the NDK zip file. My choice is: D:\work_code\android\android-ndk-r4b\
    5.2) Configure Cygwin parameters
    Go to the Cygwin folder and open Cygwin.bat. It contains something like this:
     
    @echo off
     
    C:
    chdir C:\cygwin\bin
     
    bash --login -i
     
    Using any text editor change it to:
     
    @echo off
     
    set IS_UNIX=
    set DEV_ROOT=d:/work_code/android/BlueInput
    set JAVA_HOME=c:/Progra~1/Java/jdk1.6.0_21
    set CLASSPATH=d:/work_code/android/BlueInput/obj
    set PATH=D:/work_code/android/android-sdk-windows/tools;D:/work_code/android/android-ndk-r4b
    set ANDROID_NDK_ROOT=/cygdrive/d/work_code/android-ndk-r4b
    set NDK_PROJECT_PATH=/cygdrive/d/work_code/android/BlueInput
     
    C:
    chdir C:\cygwin\bin
     
    bash --login -i
     
    The path in the config, d:/work_code/android/BlueInput, is something I'm currently working on. Change to your Own project name. The project must be organized as follows:
    A) The JNI part (the .c and .h and Android.mk files) in:
    d:/work_code/android/BlueInput/jni
    B) The JAVA part (assets,bin,gen,jni,libs,obj,res,src with the .java files) in:
    d:/work_code/android/BlueInput
    For these paths always use forward slashes.
    5.3) Open Cygwin and browse to the NDK folder, using cd [enter] :
    5.4
    cd d:/work_code/android-ndk-r4b
    5.4) Type ./ndk-build to compile the JNI project
    5.5
    The C files have been successfully built. Now using Eclipse, you can build the Java android project, and it will include the JNI part automatically. Easy.


    Комментариев нет:

    Отправить комментарий