How to use NDK? Starting with 'hello world' app

前端 未结 4 1770
悲哀的现实
悲哀的现实 2020-12-23 11:26

I would like to see a \'Hello world\' program written in C/C++ but made to run on Android.

I know this is possible by using NDK and JNI calls. But not able to make i

4条回答
  •  甜味超标
    2020-12-23 12:18

    Install the SDK and NDK like this: https://askubuntu.com/a/732010/52975

    Plug in your device via USB and run:

    git clone https://github.com/googlesamples/android-ndk
    cd android-ndk
    git checkout a5fdebebdb27ea29cb8a96e08e1ed8c796fa52db
    cd hello-jni
    ./gradlew clean
    ./gradlew assembleDebug
    ./gradlew installAllDebug
    

    Now the app should be installed in your device.

    hello-jni is the simplest C example, and there are also C++ examples like Teapot.

    Those examples use Gradle, and there are Ant Android.mk examples under the branch android-mk. You can build those with:

     ndk-build
     android update project -p . -t android-23
     ant clean
     ant debug
     ant installd
    

    Tested on Ubuntu 16.04, Android 5.1.1.

提交回复
热议问题