日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

android NDK 编译hellojni 例子文件

發(fā)布時(shí)間:2025/3/20 编程问答 17 豆豆
生活随笔 收集整理的這篇文章主要介紹了 android NDK 编译hellojni 例子文件 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

運(yùn)行android-cmd.bat,使用cd命令切換到samples/hello-jni目錄下,

運(yùn)行android update project -p . -s,會(huì)生成build.xml文件,用于ant命令,要注意的是,編譯的時(shí)候會(huì)發(fā)生錯(cuò)誤,提示:

Error: The project either has no target set or the target is invalid.
Please provide a --target to the 'android.bat update' command.

這個(gè)時(shí)候,可以使用android list targets命令來查看當(dāng)前系統(tǒng)中的android模擬器,我有兩個(gè),如下:

I:\android\android-ndk-r7c\samples\native-activity>android.bat list targets
Available Android targets:
----------
id: 1 or "android-8"
???? Name: Android 2.2
???? Type: Platform
???? API level: 8
???? Revision: 1
???? Skins: HVGA, QVGA, WQVGA400, WQVGA432, WVGA800 (default), WVGA854
???? ABIs : armeabi
----------
id: 2 or "android-10"
???? Name: Android 2.3.3
???? Type: Platform
???? API level: 10
???? Revision: 2
???? Skins: HVGA, QVGA, WQVGA400, WQVGA432, WVGA800 (default), WVGA854
???? ABIs : armeabi

如果沒有的話,需要使用SDK的AVD Manager來創(chuàng)建一個(gè)就可以了.而我使用的是android 2.3.3的模擬器,所以我的編譯命令是:

I:\android\android-ndk-r7c\samples\native-activity>android update project -p . -
t android-10 -s
Updated and renamed default.properties to project.properties
Updated local.properties
No project name specified, using Activity name 'NativeActivity'.
If you wish to change it, edit the first line of build.xml.
Added file I:\android\android-ndk-r7c\samples\native-activity\build.xml
Added file I:\android\android-ndk-r7c\samples\native-activity\proguard.cfg

從上面看出,已經(jīng)生成了build.xml文件了.

?

運(yùn)行ant debug命令,輸出如下:

I:\android\android-ndk-r7c\samples\hello-jni>ant debug
Buildfile: I:\android\android-ndk-r7c\samples\hello-jni\build.xml

-set-mode-check:

-set-debug-files:

-set-debug-mode:

-debug-obfuscation-check:

-setup:
???? [echo] Gathering info for HelloJni...
??? [setup] Android SDK Tools Revision 16
??? [setup] Project Target: Android 2.2
??? [setup] API level: 8
??? [setup]
??? [setup] ------------------
??? [setup] Resolving library dependencies:
??? [setup] No library dependencies.
??? [setup]
??? [setup] ------------------
??? [setup]
??? [setup] WARNING: Attribute minSdkVersion in AndroidManifest.xml (3) is lower
?than the project target API level (8)

-build-setup:
???? [echo] Creating output directories if needed...

-pre-build:

-code-gen:
???? [echo] ----------
???? [echo] Handling aidl files...
???? [aidl] No AIDL files to compile.
???? [echo] ----------
???? [echo] Handling RenderScript files...
[renderscript] No RenderScript files to compile.
???? [echo] ----------
???? [echo] Handling Resources...
???? [aapt] Found Deleted Target File
???? [aapt] Generating resource IDs...

-pre-compile:

-compile:
??? [javac] Compiling 2 source files to I:\android\android-ndk-r7c\samples\hello
-jni\bin\classes

-post-compile:

-obfuscate:

-dex:
????? [dex] Converting compiled files and external libraries into I:\android\and
roid-ndk-r7c\samples\hello-jni\bin\classes.dex...

-crunch:
?? [crunch] Crunching PNG Files in source dir: I:\android\android-ndk-r7c\sample
s\hello-jni\res
?? [crunch] To destination dir: I:\android\android-ndk-r7c\samples\hello-jni\bin
\res
?? [crunch] Crunched 0 PNG files to update cache

-package-resources:
???? [aapt] Creating full resource package...
???? [aapt] Warning: AndroidManifest.xml already defines debuggable (inhttp://s
chemas.android.com/apk/res/android); using existing value in manifest.

-package:
[apkbuilder] Current build type is different than previous build: forced apkbuil
der run.
[apkbuilder] Creating HelloJni-debug-unaligned.apk and signing it with a debug k
ey...

-do-debug:
?[zipalign] Running zip align on final apk...
???? [echo] Debug Package: I:\android\android-ndk-r7c\samples\hello-jni\bin\Hell
oJni-debug.apk

debug:
[propertyfile] Creating new property file: I:\android\android-ndk-r7c\samples\he
llo-jni\bin\build.prop
[propertyfile] Updating property file: I:\android\android-ndk-r7c\samples\hello-
jni\bin\build.prop
[propertyfile] Updating property file: I:\android\android-ndk-r7c\samples\hello-
jni\bin\build.prop
[propertyfile] Updating property file: I:\android\android-ndk-r7c\samples\hello-
jni\bin\build.prop

BUILD SUCCESSFUL
Total time: 5 seconds

從上面,可以看出,生成了HelloJni-debug.apk,那么使用adb命令安裝到當(dāng)前的虛擬機(jī)上就可以了.

運(yùn)行adb install bin/HelloJni-debug.apk命令,如果出現(xiàn):error: device not found,說明你的android模擬器尚未start.

運(yùn)行后,出現(xiàn)如下提示:

185 KB/s (85934 bytes in 0.453s)
??????? pkg: /data/local/tmp/HelloJni-debug.apk
Success

轉(zhuǎn)載于:https://www.cnblogs.com/geeeknerd/archive/2013/05/09/3068898.html

總結(jié)

以上是生活随笔為你收集整理的android NDK 编译hellojni 例子文件的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。