Write led-ndk program for Android driver

1. First write Linux kernel module led

2. Header files need to be generated.

Generating header files requires an application. Therefore, the app software provided by guoembedded is used. After decompression, modify local The corresponding address of the properties file.

Open studio SH, recompile the project.

After compiling the project, execute the command in the project file folder of app.

javah -d jni -classpath /opt/android-sdk-linux/platforms/android-23/android. jar:/home/my_ Android/led\ /NDK/NDK_ APP/app/build/intermediates/classes/debug/ com. android. jack. ndk. happy. MainActivity

Where / opt / Android SDK Linux / platforms / android-23 / Android Jar is the address in the Android SDK.

/home/my_ Android/led/NDK/NDK_ App / APP / build / intermediates / classes / debug / is the address in the corresponding Android App source file project.

com. android. jack. ndk. happy. Mainactivity is the project name of Android.

After running the command, a JNI folder is generated in the directory. Where com_ android_ jack_ ndk_ happy_ MainActivity. H is the header file we need.

The file declaration is the function we need to implement.

Create NDK in JNI file_ led. C source file and makefile file Android mk

If you want to generate a static library, you can change shared to static.

Then return to the previous directory and execute the command NDK build. LIBS / armeabi / libndk will be generated_ test_ myled. So library file.

The above is the data sorting for Android driver to write led-ndk program. Thank you for your support for this site!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>