Question

I have created a JNI file in AOSP at framework\base\core\java\com\mydomain\mypackage\MyClass.java

which internally call the c files of framework\base\core\jni\mydomain\my_clas.cpp

But after compilation MyClass is not avilable through the custom SDK.

Please anybody help me to include custom JNI code in to Android SDK.

Was it helpful?

Solution

Add my_clas.cpp file to frameworks/base/core/jni/Android.mk

LOCAL_SRC_FILES:= \
       mydomain_mypackage_my_clas.cpp

This adds your .cpp file to platform.

For adding your MyClass.java file to Android SDK update Android API file (where are described all classes, which are included in SDK. Location of that file frameworks/base/api/current.txt):

make update-api

Then compile your SDK for Linux platform (for example):

make PRODUCT-sdk-sdk

Your Android SDK with custom class (MyClass.java) will be located at out/host/linux-x86/ in zip archive.

Use compiled custom Android SDK in your favorite IDE and easily call MyClass.java

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top