title: How to package "wrap.sh" shell script with android studio
body: <p>I am trying to launch my application through a wrap.sh script as in <a href="https://developer.android.com/ndk/guides/wrap-script.html#creating_the_wrap_shell_script" rel="nofollow noreferrer" title="here">here</a>, but When putting my wrap.sh in the right place, it is not bundled in my apk.</p>
  
  <p>Here is the relevant build.gradle file:</p>
  
  <pre><code>android {
      compileSdkVersion rootProject.ext.compileSdkVersion
      buildToolsVersion rootProject.ext.buildToolsVersion
      sourceSets.main {
          res.srcDirs "res"
          assets.srcDirs '../../Resources/data/app', '../../Resources/data/content'
          jniLibs.srcDirs "jni"
          java.srcDirs "javasrc"
          manifest.srcFile "AndroidManifest.xml"
      }
      buildTypes {
          sanitize_debug {
              initWith buildTypes.debug
              minifyEnabled false
              useProguard false
  
              sourceSets.main {
                  jniLibs.srcDirs +=  "jni/sanitizer/libs"
              }
  
  [...]
  
  tasks.whenTaskAdded { task -&gt;
      if (task.name == 'generateSanitize_debugBuildConfig') {
          task.dependsOn createWrapScriptAddDir
      }
  }
  
  static def writeWrapScriptToFullyCompileJavaApp(wrapFile, abi) {
      if(abi == "armeabi" || abi == "armeabi-v7a")
          abi = "arm"
      if(abi == "arm64-v8a")
          abi = "aarch64"
      if (abi == "x86")
          abi = "i686"
      wrapFile.withWriter { writer -&gt;
          writer.write('#!/system/bin/sh\n')
          writer.write('HERE="$(cd "$(dirname "$0")" &amp;&amp; pwd)"\n')
          writer.write('export ASAN_OPTIONS=log_to_syslog=false,allow_user_segv_handler=1,detect_container_overflow=0\n')
          //writer.write('export ASAN_ACTIVATION_OPTIONS=include_if_exists=/data/local/tmp/asan.options.b\n')
          writer.write("export LD_PRELOAD=\$HERE/libclang_rt.asan-${abi}-android.so\n")
          writer.write('\$@\n')
      }
  }
  
  task createWrapScriptAddDir(dependsOn: copyASANLibs) {
      for (String abi : rootProject.ext.abiFilters) {
          def dir = new File("jni/sanitizer/libs/" + abi)
          dir.mkdirs()
          def wrapFile = new File(dir, "wrap.sh")
          writeWrapScriptToFullyCompileJavaApp(wrapFile, abi)
          println "write file " + wrapFile.path
      }
  }
  </code></pre>
  
  <p>and my resulting lib folder in my apk only contains my so files (which are correctly copied from their respective "jni/sanitizer/libs/abi" folder to the lib folder in the apk) and not my wrap.sh file.</p>
  
  <p>I do actually see my wrap.sh file in my android studio folder view (and on my disk), but there is none in the apk.</p>
  
  <p>(I am trying to build in android studio my so file with sanitizer as in <a href="https://virtualrealitypop.com/oreo-ndk-secrets-7d075a9b084" rel="nofollow noreferrer" title="here">here</a>)</p>