How to Build and Run Android NDK Examples?

来源:互联网 发布:淘宝乐豆有什么用 编辑:程序博客网 时间:2024/05/16 00:08

Take the native-activity sample for example,

1)      Cd C:\Users\Qingxu_Li\AppData\Local\Android\android-ndk-r10d\samples\native-activity

2)      ndk-build

3)      Run the command below to get all available targets.

android list targets

 

Available Android targets:

----------

id: 1 or "android-21"

    Name: Android 5.0.1

    Type: Platform

    API level: 21

    Revision: 2

    Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, W

XGA720, WXGA800, WXGA800-7in, AndroidWearRound, AndroidWearSquare, AndroidWearRo

und, AndroidWearSquare

 Tag/ABIs : android-tv/armeabi-v7a, android-tv/x86, android-wear/armeabi-v7a, an

droid-wear/x86, default/armeabi-v7a, default/x86, default/x86_64

----------

id: 2 or "Google Inc.:Google APIs:21"

    Name: Google APIs

    Type: Add-On

    Vendor: Google Inc.

    Revision: 1

    Description: Android + Google APIs

    Based on Android 5.0.1 (API level 21)

    Libraries:

     * com.google.android.media.effects (effects.jar)

         Collection of video effects

     * com.android.future.usb.accessory (usb.jar)

         API for USB Accessories

     * com.google.android.maps (maps.jar)

         API for Google Maps

    Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, W

XGA720, WXGA800, WXGA800-7in, AndroidWearRound, AndroidWearSquare, AndroidWearRo

und, AndroidWearSquare

 Tag/ABIs : google_apis/x86

4)      Run the command below to generate a build.xml file. Please note that the target ID 2 is retrieved from the command above.

android update project --path . --name NativeActivity --target 2

5)      Run the command below to generate a .apk file.

ant debug

6)      adb install bin/ NativeActivity-debug.apk

7)      adb shell

Then, run the command below to launch the activity.

am start -n com.example.native_activity/android.app.NativeActivity

8)      Now, you can run “adb logcat” to see the logs generated by this native activity.

I/native-activity( 1240): accelerometer: x=9.776220 y=0.000000 z=0.813417

I/native-activity( 1240): accelerometer: x=9.776220 y=0.000000 z=0.813417

I/native-activity( 1240): accelerometer: x=9.776220 y=0.000000 z=0.813417

I/native-activity( 1240): accelerometer: x=9.776220 y=0.000000 z=0.813417

I/native-activity( 1240): accelerometer: x=9.776220 y=0.000000 z=0.813417

I/native-activity( 1240): accelerometer: x=9.776220 y=0.000000 z=0.813417

I/native-activity( 1240): accelerometer: x=9.776220 y=0.000000 z=0.813417

I/native-activity( 1240): accelerometer: x=9.776220 y=0.000000 z=0.813417

 

0 0
原创粉丝点击