title: How to build portable binary using Android private APIs
body: <p>I'm working on the application which uses some of the Android private APIs. I build it as part of full Android (CM10) sources configured for my phone. The resulting binary works great on that device but throws Segmentation faults on other devices with the same Android version. It's not a problem of missing APIs because even a simple hello world compiled that way throws Segfault. Here is a sample code:</p>
  
  <p>hello-cmd.cpp</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  
  int main(int argc, char* argv[]) {
      printf("Hello Command Line!");
      return 0;
  }
  </code></pre>
  
  <p>Android.mk</p>
  
  <pre><code>LOCAL_PATH := $(call my-dir)
  include $(CLEAR_VARS)
  LOCAL_MODULE    := hello-cmd
  LOCAL_SRC_FILES := hello-cmd.cpp
  include $(BUILD_EXECUTABLE)
  </code></pre>
  
  <p>When I build the following code with Android NDK it is portable. When I build it inside android sources it's not.</p>
  
  <p>I guess the problem is a linker configuration but I don't know how to debug or fix this.</p>