title: dlopen for different flavors in android
body: <p>I have a native lib in my android project where it opens .so files.
  My android app has two flavours and they have different application ids.
  In my <code>.c</code>code I use <code>ldopen</code> like this:</p>
  
  <pre><code>handle  = dlopen("/data/data/&lt;application.id&gt;/lib/libffmpeg.so", RTLD_LAZY);
  </code></pre>
  
  <p>So it works only for one of flavors at a time.</p>
  
  <p>I tried to fix it with <code>#ifdef</code> directive:</p>
  
  <pre><code>#ifdef STAGE
    handle  = dlopen("/data/data/&lt;application.id.stage&gt;/lib/libffmpeg.so", RTLD_LAZY);
  #else
    handle  = dlopen("/data/data/&lt;application.id&gt;/lib/libffmpeg.so", RTLD_LAZY);
  #endif
  </code></pre>
  
  <p>I'm trying to define STAGE in my <code>build.gradle</code> file but can't find a way to do this. 
  Here is a task I use for building native ources: </p>
  
  <pre><code>task buildNative(type: Exec, description: 'Compile JNI source via NDK') {
      Properties properties = new Properties()
      properties.load(project.rootProject.file('myProject/local.properties').newDataInputStream())
      def ndkdir = properties.getProperty('ndk.dir', null)
  
      def command = "$ndkdir/ndk-build";
      if (Os.isFamily(Os.FAMILY_WINDOWS)) {
          script += '.cmd'
      }
  
      commandLine "$command",
              '-C', file('src/main/libs').absolutePath, // Change src/main/jni the relative path to your jni source
              '-j', Runtime.runtime.availableProcessors(),
              'all',
              'NDK_DEBUG=1',
              'APP_CFLAGS=-DSTAGE'
  }
  
  tasks.withType(JavaCompile) {
      compileTask -&gt; compileTask.dependsOn buildNative
  }
  </code></pre>
  
  <p>Can someone suggest me how to do this ?</p>
  
  <p>P.S. probably the question is really stupid or I'm trying to do it in completely wrong way. Sorry for that but I have really small experience in c/c++ so I have no idea what all these <code>LOCAL_C_INCLUDES</code>, <code>LOCAL_CFLAGS</code> etc. does.
  Thanks.</p>