• NDK FAQ


    1.

    cygwin 路径模式/cygdrive/<Drive letter>/<Path to your directory with forward 
    slashes>. 比如:如果ant安装在 c:\ant, 在cygwin里是这样的引用 /cygdrive/c/ant

    为了解决这个问题,打开cygwin安装目录下的home/<用户名>/.bash_profile文件,添加环境变量。

    如下:

    export ANT_HOME=`cygpath –u "$ANT_HOME"`
    export JAVA_HOME=`cygpath –u "$JAVA_HOME"`
    export ANDROID_SDK=`cygpath –u "$ANDROID_SDK"`
    export ANDROID_NDK=`cygpath –u "$ANDROID_NDK"`

     

    反引号表示调用命令。但是这样是会找不到windows下面的目录的。因为cygpath –u “$ANT_HOME “命令输出的路径前面有空格,cygwin不能正常识别。

    解决办法:手动添加路径如下:

    export ANT_HOME="/cygdrive/c/apache-ant/"
    export JAVA_HOME="/cygdrive/c/Java/jdk1.7.0"
    export ANDROID_SDK="/cygdrive/f/project/android/develop_tools/android-sdk-windows"
    export ANDROID_NDK="/cygdrive/f/project/android/develop_tools/android-ndk-r8e"

     

    2.使用ant编译工程时,生成ant编译配置文件,在windows上的NDK目录下用命令 android  command . 

    比如android update project –p .时会提示错误:Error: The project either has no target set or the target is invalid.

    解决办法:

    使用命令android update project -t 2 -p .

    参数-t指定target ID ,可通过android list target 获得

    3.
    ant install 失败,提示'ant install' now requires the build target to be specified as well.

    解决办法:
    如果是测试的话,使用 
    ant debug install

     

    4.javah 的使用

    -classpath 参数指定包含jni方法的class文件存放目录

    -bootclasspath 参数代表android.jar存放目录,不然编译时找不到Activity.class

    -d 指定目标头文件存放的目录

    比如在SRC目录下输入:javah -classpath ../bin/classes -bootclasspath F:\project\android\develop_tools\android-sdk-windows\platforms\android-17\android.jar com.test.MainActivity

     

    在Eclipse中开发生成头文件时可以这样设置:

    点击Run->External tools->External tools Configurations

    New 一个Program,设置如下:

     

    5.eclipse编译android projecet中的c/c++

      1.  Open menu File | New | Other....
      2.  Under C/C++, select Convert to a C/C++ Project and click on Next.
      3.  Check MyProject, choose MakeFile project and Other Toolchain and
      finally click on Finish.
      4.  Open C/C++ perspectve when requested.
      5.  Right-click on MyProject in Project explorer view and select Propertes.

       6.  In the C/C++ Build secton, uncheck Use default build command and enter
        ndk-build as a Build command.

                 

    这样NDK就能正常编译C/C++文件,提示编译中的错误

    6.将NDK头文件加入到工程中,比如jni.h

      11. Let's go back to project propertes one last tme. Go to secton C/C++ General/Paths
      and Symbols and then in Includes tab.
      12. Click on Add... and enter the path to the directory containing this include fle which
      is located inside NDK's platforms directory. In our case, we use Android 2.3.3 (API
      level 9), so the path is ${env_var:ANDROID_NDK}/platforms/android-9/
      arch-arm/usr/include. Environment variables are authorized and encouraged!

         

  • 相关阅读:
    点、面状地物对象的时态GIS
    关于dijit.form.ComboBox 赋值,更新值
    远程桌面超出最大连接数时强制登录
    SQL和excel数据互导入
    google map api 二三维联动 参考
    PowerDesign设置列名与表名的大小写规则
    Nunit在VS2010加载不了程序集的解决办法
    缩写
    Python 自用脚本
    UVM项目随笔
  • 原文地址:https://www.cnblogs.com/chyl411/p/3116490.html
Copyright © 2020-2023  润新知