1

I've added the following to my build.gradle to include pre-compiled binaries and shared objects in my jni folder.

sourceSets {
  main {
     jniLibs.srcDir file('jni/')
  }
}

But when I build and inspect the APK, the .so files are included, but the binaries are not. Is it possible for gradle to bundle the compiles binaries?

stealthcopter
  • 13,964
  • 13
  • 65
  • 83

1 Answers1

0

No, the goal is to store .so files that are automatically extracted upon installation.

Anything custom should go in your assets folder.

Xavier Ducrohet
  • 28,383
  • 5
  • 88
  • 64
  • So then... I should put the native binaries in the assets folder, and then at runtime copy them, make them executable and run them? – stealthcopter Feb 16 '14 at 22:01
  • That would be the right approach but I'm not sure if it'll work. You'll also need to manually figure out the ABI of the device and use the right binary. – Xavier Ducrohet Feb 16 '14 at 23:09
  • Yeah, it seems overkill. I think it would be better to just include the binaries inside the libs folder in the apk using a gradle task, just like how the previous build systems do (unless I'm missing something fundamental?) – stealthcopter Feb 17 '14 at 00:42
  • Neither Ant nor ADT will package anything but .so – Xavier Ducrohet Feb 17 '14 at 06:23
  • That can't be true, as I have project that includes a FFMPEG binary (libs/armeabi/ffmpeg) which gets included in the final apk (lib/armeabi/ffmpeg). – stealthcopter Feb 17 '14 at 10:09
  • Interesting. What build system are you using? – Xavier Ducrohet Feb 17 '14 at 17:26
  • This was using intellij about a year ago. I can't seem to find any documentation to support bundling of native binaries in this way so I figure it was a mistake of the build system and I should seek an alternate method (this answer seems promising http://stackoverflow.com/a/5642593/315998) – stealthcopter Feb 18 '14 at 00:36
  • It seems in Android 10, you can't copy the executables out any more. You have to run them from the right location. – mjaggard Dec 11 '19 at 19:38