Вопрос

Hello StackOverFlow experts,

I am very new to Android programming and unfortunately my first project in Android involves using C++ libraries. These are third party libraries and they have to be used. Also, I am not familiar with C++. I have successfully installed Android SDK (v4.2.2 and APIv 17) and NDK (android-ndk-r8e). I was able to compile the C++ code and build the eclipse project and see the application running on my Android device.

But today I learnt that I have to compile a C++ preprocessor directive to make some functionality work. As I understand C++ preprocessor directive is executed before the actual compilation of code. Now, thanks to google, I learnt that the way to execute the preprocessor directive is to modify the makeall.sh file and I did the following:

ARCH="armeabi armeabi-v7a mips x86"
LIBDIR=../../mpcore/lib.android/libs

tmpdir=`mktemp -d /tmp/$0.XXXXX`

for arch in $ARCH; do
 /Users/Desktop/android-ndk-r8e/ndk-build LOCAL_CPPFLAGS:=-DUSE_ORIGINAL_BACKGROUND LOCAL_LDFLAGS=-L$LIBDIR/$arch APP_ABI=$arch
cp libs/$arch/libsample.so $tmpdir/libsample.so.$arch
done

for arch in $ARCH; do
 cp $tmpdir/libsample.so.$arch libs/$arch/libsample.so
done

rm -rf $tmpdir

where USE_ORIGINAL_BACKGROUND is the name of my C++ directive.

When I run the makeall.sh it compiles well (atleast I don't see any error). Then I open my eclipse project, refresh it and then build the APK file. But, unfortunately, I don't see the expected results.

So my question to all: Am I missing something? The way I have modified my makeall.sh sounds correct to you?

Pardon me, if this question is very elementary to you all but it will really help me to learn and make progress learning Android. Thank you all in advance

Это было полезно?

Решение

I got the issue fixed. It seems that I needed to delete all the existing compiled C++ code from the libs and the obj folders. Then I refreshed the eclipse project, copied the APK file to my Android device and it worked!!!

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top