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
本文介绍如何使用Android NDK构建一个简单的Native Activity应用。从初始化项目到安装并运行应用的全过程,包括获取目标平台、更新项目配置、编译生成APK文件及通过ADB命令安装启动应用等步骤。
2470

被折叠的 条评论
为什么被折叠?



