Requirements
- Dev phone (Hopefully I'll create a better version soon)
- Android SDK 1.5
- Sourcery G++ Lite 2009q1-176 (It's the one I used although EABI might be correct)
- Create a new Android project in eclipse
- Create an empty folder (native) in the root of the project
- Setup your main activity
- Setup your static java class to call your native library
- Generate header files as per any JNI project
- cd /path-to-android-project/native/
- javah -classpath /path-to-sdk
/platforms/android-1.5/android.jar:../bin/ com.example.StaticNativeWrapper - Write your native file to match the header file generated
- Copy the modified armelf_linux_eabi.xsc to your 'native' folder to find out how and why it's modified check out motz diary.
- Compile and link the headers from step 5 and the native code from step 6
- arm-none-linux-gnueabi-gcc -I/usr/lib/jvm/java-6-sun/include -I/usr/lib/jvm/java-6-sun/include/linux -fpic -c uk_ac_ic_doc_gea05_miffedjni_nativewrappers_NativeAdd.c
- arm-none-linux-gnueabi-ld -T armelf_linux_eabi.xsc -shared -o libNativeAdd.so uk_ac_ic_doc_gea05_miffedjni_nativewrappers_NativeAdd.o
- Put the library on your sdcard and put it in the data for your application;
- adb push libNativeAdd.so /sdcard/native/libNativeAdd.so
- adb shell
- # cat /sdcard/native/libNativeAdd.so >/data/data/com.example.application/libNativeAdd.so
- Install your application and enjoy!
- adb install ../bin/Application.apk
Feel free to check out my project over svn and play around with it.
Have fun!