<div dir="ltr"><div><div>1. Import project.<br></div>2. Open project.<br></div>3. Edit
the app build.gradle. Here is the important part of mine. I have an
Android phone running 4.4.2, so I used SDK version 19. Take notice of
the cFlags settings! You can include whatever you need.<br><br><pre style="background-color:#ffffff;color:#000000;font-family:'DejaVu Sans Mono';font-size:9.1pt">android {<br> compileSdkVersion <span style="color:#0000ff">19<br></span><span style="color:#0000ff"> </span>buildToolsVersion <span style="color:#008000;font-weight:bold">"19.1"<br></span><span style="color:#008000;font-weight:bold"><br></span><span style="color:#008000;font-weight:bold"> </span>defaultConfig {<br> applicationId <span style="color:#008000;font-weight:bold">"com.example.ccrisler.cameratest"<br></span><span style="color:#008000;font-weight:bold"> </span>minSdkVersion <span style="color:#0000ff">19<br></span><span style="color:#0000ff"> </span>targetSdkVersion <span style="color:#0000ff">19<br></span><span style="color:#0000ff"> </span>versionCode <span style="color:#0000ff">1<br></span><span style="color:#0000ff"> </span>versionName <span style="color:#008000;font-weight:bold">"1.0"<br></span><span style="color:#008000;font-weight:bold"><br></span><span style="color:#008000;font-weight:bold"> </span>ndk {<br> moduleName <span style="color:#008000;font-weight:bold">"CameraTest"<br></span><span style="color:#008000;font-weight:bold"> </span>cFlags <span style="color:#008000;font-weight:bold">"-DANDROID_NDK -D_DEBUG -I/home/ccrisler/gstreamer_android_armv7_debug/include/gstreamer-1.0/gst"<br></span><span style="color:#008000;font-weight:bold"> </span><span style="color:#808080;font-style:italic">// cFlags "-std=c++11 =fexceptions" // Add provisions to allow C++ 11 functionality<br></span><span style="color:#808080;font-style:italic"> </span>}<br> }<br><br> sourceSets.<span style="color:#008000">main </span>{<br> jni.srcDirs = [] <span style="color:#808080;font-style:italic">// This prevents the auto generation of Android.mk<br></span><span style="color:#808080;font-style:italic"> </span>jniLibs.srcDir <span style="color:#008000;font-weight:bold">'src/main/libs'<br></span><span style="color:#008000;font-weight:bold"> </span>}<br><br></pre><pre style="background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:"DejaVu Sans Mono";font-size:9.1pt">4. Edit local.properties. Add ndk.dir=<absolute path to your NDK><br></pre><pre style="background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:"DejaVu Sans Mono";font-size:9.1pt">5. Outside of Android Studio, edit <a href="http://android.mk" target="_blank">android.mk</a> to set some GStreamer parameters. Here is mine. I think that it comes from the GStreamer examples and I<br>copy it to each project.<br><br>LOCAL_PATH := $(call my-dir)<br><br>include $(CLEAR_VARS)<br><br>LOCAL_MODULE := CameraTest<br>LOCAL_SRC_FILES := MediaProcessing.c<br>LOCAL_SHARED_LIBRARIES := gstreamer_android<br>LOCAL_LDLIBS := -llog -landroid<br>include $(BUILD_SHARED_LIBRARY)<br><br>GSTREAMER_JAVA_SRC_DIR := app/src/main/java<br>GSTREAMER_ROOT := <absolute path>/gstreamer_android_armv7_debug<br><br>ifndef GSTREAMER_ROOT<br>ifndef GSTREAMER_ROOT_ANDROID<br>$(error GSTREAMER_ROOT_ANDROID is not defined!)<br>endif<br>GSTREAMER_ROOT := $(GSTREAMER_ROOT_ANDROID)<br>endif<br>GSTREAMER_NDK_BUILD_PATH := $(GSTREAMER_ROOT)/share/gst-android/ndk-build/<br>include $(GSTREAMER_NDK_BUILD_PATH)/<a href="http://plugins.mk" target="_blank">plugins.mk</a><br>GSTREAMER_PLUGINS := $(GSTREAMER_PLUGINS_CORE) $(GSTREAMER_PLUGINS_PLAYBACK) $(GSTREAMER_PLUGINS_CODECS) $(GSTREAMER_PLUGINS_NET) $(GSTREAMER_PLUGINS_SYS)<br>G_IO_MODULES := gnutls<br>GSTREAMER_EXTRA_DEPS := gstreamer-video-1.0<br>include $(GSTREAMER_NDK_BUILD_PATH)/<a href="http://gstreamer-1.0.mk" target="_blank">gstreamer-1.0.mk</a><br><br></pre><pre style="background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:"DejaVu Sans Mono";font-size:9.1pt">6. Open a terminal window. On linux, 'export NDK_PROJECT_PATH=<absolute path to project>android_tutorial-N/app/src/main'<br><br></pre><pre style="background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:"DejaVu Sans Mono";font-size:9.1pt">7. Run ndk-build APP_PLATFORM=android-9<br><br></pre><pre style="background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:"DejaVu Sans Mono";font-size:9.1pt">I have forgotten what the APP_PLATFORM does, but it changes a version of the system files used to prevent many unresolved references.<br></pre><pre style="background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:"DejaVu Sans Mono";font-size:9.1pt">You can google it for more info. When you run ndk-build, it will build your GStreamer android libraries and put everything in the 'right'<br></pre><pre style="background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:"DejaVu Sans Mono";font-size:9.1pt">places. It will create your JNI and libs directories. Obviously, if you change any of the C code, you have to run ndk-build again.<br></pre><pre style="background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:"DejaVu Sans Mono";font-size:9.1pt"><br></pre><pre style="background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:"DejaVu Sans Mono";font-size:9.1pt">Here is a great link for NDK info-><a href="http://www.shaneenishry.com/blog/2014/08/17/ndk-with-android-studio/" target="_blank">http://www.shaneenishry.com/blog/2014/08/17/ndk-with-android-studio/</a><br></pre><pre style="background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:"DejaVu Sans Mono";font-size:9.1pt">I still can't find Sebastian's blog! Sorry.<br></pre><br clear="all"><br></div>