Android-NDK______1.环境搭建

  1. export ANDROID_SDK=”<path to your Android SDK directory>”
           export ANDROID_NDK=”<path to your Android NDK directory>”
    
           export PATH=”$PATH:$ANDROID_SDK/tools:$ANDROID_SDK/platform-
           tools:$ANDROID_NDK”
    
    
    
    
    
    //Test
  1. Open a command-line prompt (or Cygwin prompt on Windows)

  2. Go to hello-jnisample directory inside the Android NDK. All the following stepshave to performed from this directory:

           $ cd $ANDROID_NDK/samples/hello-jni
    
  3. Create Ant build file and all related configuration files automatically usingandroidcommand (android.baton Windows). These files describe how to compile andpackage an Android application:

    //生成ant自动打包

           android update project –p .
    
    // 如果想制订编译的target
    android update project -p . --target android-8
    
  4. Buildlibhello-jninative library withndk-build, which is a wrapper Bashscript around Make. Commandndk-buildsets up the compilation toolchain fornative C/C++ code and calls automatically GCC version featured with the NDK.

    $ ndk-build 

    1. Make sure your Android development device or emulator is connected and running.

    2. Compile, package, and install the final HelloJni APK (an Android applicationpackage). All these steps can be performed in one command, thanks to Ant buildautomation tool. Among other things, Ant runs javacto compile Java code, AAPTto package the application with its resources, and finally ADB to deploy it on thedevelopment device. Following is only a partial extract of the output:

      最新的使用

      ant debug install

      //$ ant install 

      1. Launch a shell session using adb(oradb.exeon Windows). ADB shell is similar toshells that can be found on the Linux systems:

        $ adb shell

      2. From this shell, launch HelloJni application on your device or emulator. To do so, useam, the Android Activity Manager. Commandamallows to start Android activities,services or sending intents (that is, inter-activity messages) from command line.Command parameters come from the Android manifest:

               # am start -a android.intent.action.MAIN -n com.example.hellojni/
               com.example.hellojni.HelloJni
        
        
        
        启动Activity
      3. Finally, look at your development device. HelloJni appears on the screen! 

         就看到了结果




page57image12136 page57image12296 page57image12456

$ ndk-build

page57image13544

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值