How to include multiple c files to compile in android NDK?

I ran into problem when I had multiple C files in my project. Single C file was OK for me.
I was getting undefined reference error while doing this.
Then I found out the solution after a lot of search in google.

You can check this post before going through this post.
This is about setting up NDK in MAC.
Starting with NDK for Android – A Simple example. OR How to run a C code in android?

I have to make the change in the Android.mk file to include other files to compile.

This is the content of my Android.mk file

LOCAL_PATH := $(call my-dir)
 
include $(CLEAR_VARS)
 
LOCAL_LDLIBS := -llog
 
LOCAL_MODULE    := ndksetup
LOCAL_SRC_FILES := native.c test.c test_2.c
 
include $(BUILD_SHARED_LIBRARY)

Here is my native.c code in which I am including those two files test.c and test2.c


#include <jni.h>
#include <string.h>
#include <android/log.h>

// my test file 
#include "test.h"
#include "test_2.h"

#define DEBUG_TAG "NDKSetupActivity"
 
void Java_com_ndksetup_NDKSetupActivity_printLog(JNIEnv * env, jobject this, jstring logString)
{
    jboolean isCopy;
    const char * szLogString = (*env)->GetStringUTFChars(env, logString, &isCopy);
 
    __android_log_print(ANDROID_LOG_DEBUG, "TAGGGGG", "NDK: %s", szLogString);
 
    (*env)->ReleaseStringUTFChars(env, logString, szLogString);
}
int Java_com_ndksetup_NDKSetupActivity_fibonacci(int value)
{
	int p = 8;
	printMe();
	printMe2();
	return p;
}

How to get Device Orientation in Cocos2D, iPhone in Objective C?

Hello all……
We may need to know that what is your current device orientation.
Using the below code you can do this.

if([[UIDevice currentDevice] orientation] == kCCDeviceOrientationPortrait) {
            NSLog(@"Device is now in Portrait Mode");
}
else if ([[UIDevice currentDevice] orientation] == kCCDeviceOrientationLandscapeLeft) {
            NSLog(@"Device is now in LandscapeLeft Mode ");
}
else if ([[UIDevice currentDevice] orientation] == kCCDeviceOrientationLandscapeRight) {
            NSLog(@"Device is now in LandscapeRight Mode");
}
else if([[UIDevice currentDevice]orientation] ==
  kCCDeviceOrientationPortraitUpsideDown) {
            NSLog(@"Device is now in PortraitUpsideDown Mode");
ss="Apple-style-span" style="font-weight: normal;">
}

Note: If you have to explicitly set the orientation of your phone to any of the above you can set this in the appDelegate.m file. You can put an “||” (OR) symbol in between to set more than one.

Please leave your valuable comments if this post was useful…..