Index: pjproject/trunk/pjsip-apps/src/pjsua/android/jni/Android.mk
===================================================================
--- pjproject/trunk/pjsip-apps/src/pjsua/android/jni/Android.mk	(revision 5318)
+++ 	(revision )
@@ -1,63 +1,0 @@
-# $Id$
-
-LOCAL_PATH	:= $(call my-dir)
-include $(CLEAR_VARS)
-
-# Get PJ build settings
-include ../../../../build.mak
-include $(PJDIR)/build/common.mak
-
-# Path to SWIG
-MY_SWIG		:= swig
-
-MY_MODULE_PATH  := $(PJDIR)/pjsip-apps/build/output/pjsua-$(TARGET_NAME)
-MY_MODULES      := $(MY_MODULE_PATH)/pjsua_app.o \
-		   $(MY_MODULE_PATH)/pjsua_app_cli.o \
-		   $(MY_MODULE_PATH)/pjsua_app_common.o \
-		   $(MY_MODULE_PATH)/pjsua_app_config.o \
-		   $(MY_MODULE_PATH)/pjsua_app_legacy.o
-
-# Constants
-MY_JNI_WRAP	:= pjsua_wrap.cpp
-MY_JNI_DIR	:= jni
-
-# Android build settings
-LOCAL_MODULE    := libpjsua
-LOCAL_CFLAGS    := -Werror $(APP_CFLAGS)
-LOCAL_LDFLAGS   := $(APP_LDFLAGS)
-LOCAL_LDLIBS    := $(MY_MODULES) $(APP_LDLIBS)
-LOCAL_SRC_FILES := $(MY_JNI_WRAP) pjsua_app_callback.cpp
-LOCAL_CPP_FEATURES += exceptions rtti
-
-# Copy Java Camera helper components from pjmedia/src/pjmedia-videodev/android
-src/org/pjsip/PjCamera.java:
-ifneq (,$(findstring PJMEDIA_VIDEO_DEV_HAS_ANDROID=1,$(ANDROID_CFLAGS)))
-	@echo "Copying Android camera helper components..."
-	cp $(PJDIR)/pjmedia/src/pjmedia-videodev/android/PjCamera*.java src/org/pjsip
-endif
-
-# Invoke SWIG
-$(MY_JNI_DIR)/$(MY_JNI_WRAP): src/org/pjsip/PjCamera.java
-	@echo "Invoking SWIG..."
-	$(MY_SWIG) -c++ -o $(MY_JNI_DIR)/$(MY_JNI_WRAP) -package org.pjsip.pjsua -outdir src/org/pjsip/pjsua -java $(MY_JNI_DIR)/pjsua.i
-
-.PHONY: $(MY_JNI_DIR)/$(MY_JNI_WRAP)
-
-include $(BUILD_SHARED_LIBRARY)
-
-
-# Add prebuilt libopenh264, if configured
-ifneq (,$(OPENH264_LDFLAGS))
-include $(CLEAR_VARS)
-LOCAL_MODULE := libopenh264
-LOCAL_SRC_FILES := $(subst -L,,$(filter -L%,$(OPENH264_LDFLAGS)))/libopenh264.so
-include $(PREBUILT_SHARED_LIBRARY)
-endif
-
-# Add prebuilt libyuv, if configured
-ifneq (,$(LIBYUV_LDFLAGS))
-include $(CLEAR_VARS)
-LOCAL_MODULE := libyuv
-LOCAL_SRC_FILES := $(subst -L,,$(filter -L%,$(LIBYUV_LDFLAGS)))/libyuv.so
-include $(PREBUILT_SHARED_LIBRARY)
-endif
Index: pjproject/trunk/pjsip-apps/src/pjsua/android/jni/Application.mk
===================================================================
--- pjproject/trunk/pjsip-apps/src/pjsua/android/jni/Application.mk	(revision 5318)
+++ 	(revision )
@@ -1,2 +1,0 @@
-# It might be necessary to define APP_ABI if you are using other than armeabi, e.g: arm64-v8a
-# APP_ABI := arm64-v8a
Index: pjproject/trunk/pjsip-apps/src/pjsua/android/jni/Makefile
===================================================================
--- pjproject/trunk/pjsip-apps/src/pjsua/android/jni/Makefile	(revision 5506)
+++ pjproject/trunk/pjsip-apps/src/pjsua/android/jni/Makefile	(revision 5506)
@@ -0,0 +1,56 @@
+include ../../../../../build.mak
+include ../../../../../build/common.mak
+
+MY_MODULE_PATH  := $(PJDIR)/pjsip-apps/build/output/pjsua-$(TARGET_NAME)
+MY_MODULES      := $(MY_MODULE_PATH)/pjsua_app.o \
+		   $(MY_MODULE_PATH)/pjsua_app_cli.o \
+		   $(MY_MODULE_PATH)/pjsua_app_common.o \
+		   $(MY_MODULE_PATH)/pjsua_app_config.o \
+		   $(MY_MODULE_PATH)/pjsua_app_legacy.o
+
+OUT_DIR		:= ../build/jni
+LIBPJSUA_SO	:= ../app/src/main/jniLibs/armeabi/libpjsua.so
+
+# Env settings, e.g: path to SWIG, JDK, java(.exe), javac(.exe)
+MY_SWIG		:= swig
+MY_JNI_CFLAGS   := -D__ANDROID__
+MY_JNI_LDFLAGS  := -Wl,-soname,libpjsua.so
+SWIG_FLAGS      := -D__ANDROID__ -c++
+
+# Build settings
+MY_CFLAGS	:= $(PJ_CXXFLAGS) $(CFLAGS)
+MY_LDFLAGS	:= $(PJ_LDXXFLAGS) $(PJ_LDXXLIBS) $(LDFLAGS)
+MY_PACKAGE_NAME	:= org.pjsip.pjsua
+MY_PACKAGE_PATH := ../app/src/main/java/$(subst .,/,$(MY_PACKAGE_NAME))
+
+all: $(LIBPJSUA_SO) java
+
+$(LIBPJSUA_SO): $(OUT_DIR)/pjsua_wrap.o
+	mkdir -p ../app/src/main/jniLibs/armeabi
+	$(PJ_CXX) -shared -o $(LIBPJSUA_SO) \
+	$(OUT_DIR)/pjsua_wrap.o $(OUT_DIR)/pjsua_app_callback.o \
+	$(MY_MODULES) \
+		$(MY_CFLAGS) $(MY_LDFLAGS)
+
+$(OUT_DIR)/pjsua_wrap.o: $(OUT_DIR)/pjsua_wrap.cpp pjsua_app_callback.cpp Makefile
+	$(PJ_CXX) -c $(OUT_DIR)/pjsua_wrap.cpp -o $(OUT_DIR)/pjsua_wrap.o \
+		$(MY_CFLAGS)
+	$(PJ_CXX) -c pjsua_app_callback.cpp -o $(OUT_DIR)/pjsua_app_callback.o \
+		$(MY_CFLAGS)
+
+$(OUT_DIR)/pjsua_wrap.cpp: pjsua.i
+	mkdir -p $(MY_PACKAGE_PATH)
+	mkdir -p $(OUT_DIR)
+	swig $(SWIG_FLAGS) -java  -package $(MY_PACKAGE_NAME) \
+		-outdir $(MY_PACKAGE_PATH) \
+		-o $(OUT_DIR)/pjsua_wrap.cpp pjsua.i
+
+clean distclean realclean:
+	rm -rf $(LIBPJSUA_SO) $(OUT_DIR)/* \
+		$(MY_PACKAGE_PATH)/*.java
+
+java:
+ifneq (,$(findstring PJMEDIA_VIDEO_DEV_HAS_ANDROID=1,$(ANDROID_CFLAGS)))
+	@echo "Copying Android camera helper components..."
+	cp $(PJDIR)/pjmedia/src/pjmedia-videodev/android/PjCamera*.java $(MY_PACKAGE_PATH)/..
+endif
Index: pjproject/trunk/pjsip-apps/src/pjsua/android/jni/pjsua.i
===================================================================
--- pjproject/trunk/pjsip-apps/src/pjsua/android/jni/pjsua.i	(revision 5318)
+++ pjproject/trunk/pjsip-apps/src/pjsua/android/jni/pjsua.i	(revision 5506)
@@ -2,6 +2,6 @@
 
 %{
-#include "pjsua_app_callback.h"
-#include "../../pjsua_app.h"
+#include "../../jni/pjsua_app_callback.h"
+#include "../../../pjsua_app.h"
 
 #if defined(PJMEDIA_HAS_VIDEO) && PJMEDIA_HAS_VIDEO!=0
