ҳ
ǰλ: ҳ > > Android̳ >

JNI Androidƽ̨֮һʵ(·롢鴫롢)

ʱ:2016-11-11 22:14Դ:Խ̳ѧϰ www.etwiki.cn ༭:admin

C++ʵֶдļJavaΪ·ĴݺĴ봫

1.׼

װJDKߵ64λ汾1.8.0_60ȷû

װadtõadt-bundle-windows-x86_64-20131030ҪĿȥҵءhttp://pan.baidu.com/s/1ntZ5V7b

װndkõandroid-ndk-r9ҪĿȥҵءhttp://pan.baidu.com/s/1c1foakg

2.

(1) ½Android

File->New->Android Application Project

Application Name:WriteReadJĬϡ

 


(2)˵Window->PreferencesPreferencesԻУѡAndroid->NDKдNDK Locationandroid-ndk-r9cλá

 


(3) Ŀ½jniļУļڷC/C++Դļȡ

(4) jniԶѡBuilder

ʾӢԭģhttp://mobilepearls.com/labs/ndk-builder-in-eclipse/

(a) ½һBuilderProject->Properties->Builders->New

(b) ڵChoose configuration typeԻ˫Program(ѡProgramOK)

 


(c) ڵEdit ConfigurationԻУNameBuilders(ȡ)

ѡMain

Locationndk-build.cmd·ԵBrowser File Systemťѡ·

Working Directory룬Browser WorkspaceѡWriteReadJ

 


ѡRefresh

ѡRefresh resources upon completion.

ѡThe entire workspace

ѡRecursively include sub-folders

 


ѡBuild options

ѡAfter a "Clean"(ѡֻҪCleanһĿͿʼ)

ѡDuring manual builds

ѡDuring auto builds

ѡ Specify working set of relevant resources

 


Specify Resources...ѡWriteReadJĿjniĿ¼Finish

 


OKɡ

3.дjava(μJNI Windowsƽ̨)

(1) ½һ

Packagecom.yiluboke.zxy

NameWriteReadJ

Ĭ

 


(2) ޸MainActivityonCreateĴ

4.jniļ£ļдC++(μJNI Windowsƽ̨)

(1) ҵAndroidĿbinĿ¼µclassesļУĿ¼eclipseԶɵֽļ

cmd\WriteReadJ\bin\classes·£javah com.yiluboke.zxy.WriteReadJس

 


\WriteReadJ\bin\classesĿ¼£ͷļcom_yiluboke_zxy_WriteReadJ.hļjniĿ¼С

 


(2) дC++롣

5.jniļ£½ļAndroid.mkApplcation.mkݷֱ£

Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_CPP_EXTENSION := .cpp
LOCAL_MODULE := jniwritereadfile
LOCAL_SRC_FILES := com_yiluboke_zxy_WriteReadJ.cpp writeReadDo.cpp
include $(BUILD_SHARED_LIBRARY)

Applcation.mk

APP_MODULES := jniwritereadfile
APP_ABI := all
APP_PLATFORM := android-19
APP_STL := stlport_static

LOCAL_PATH C/C++Ŀ¼jniĿ¼


my-dirDZϵͳṩĺ꺯Android.mkĿ¼·

LOCAL_CPP_EXTENSION Ҫļչ

LOCAL_MODULE ҪĿơԶǰlib.so

LOCAL_SRC_FILES ҪC/C++ļ

аٶȡ


6.AndroidManifest.xmlĴöдSDȨ
<!--SDCardдɾļȨ -->
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
<!-- SDCardдȨ -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<!-- SDCardȡȨ -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

7.Project->Clean->ѡWriteReadJԶ룬ԿlibsĿ¼libjniwritereadfile.soļɡ

8.WriteReadJ

ʹС

ûģЧɡ

 

 

9.Demo

ٶ̵ַhttp://pan.baidu.com/s/1geyKTUj

IJõJDK 64λ汾1.8.0_60

Android NDK: WARNING: APP_PLATFORM android-19 is larger than android:minSdkVersion 8 in ./AndroidManifest.xml

AndroidManifest.xml޸SDKΪʵİ汾

ߵ:

 


޸Ϊ
<uses-sdk
android:minSdkVersion="19"
android:targetSdkVersion="19" />

һ
(0)
0%
һ
(0)
0%
ǩ(Tag):Android android̳ android android android̳
------ָ----------------------------
------ָ----------------------------
Ծػص߷棬Ͻɫ顢ۡ
:
:
֤:ҸͼƬ
Ƽ