6

An android application have two modules and one depend on the other, and the common used jars and native libraries are defined in parent-project, while the child-project add it as a dependency in the build.gradle:

enter image description here

However after I build the child-project I found that the jars put insiede the parent-project are copied to the apk, while the native libraries are not. Only the native libraries inside the child-project are packaged to the apk.

What's going on?

With Android studio 1.0.2.

hguser
  • 35,079
  • 54
  • 159
  • 293

1 Answers1

12

I had the same issue. The problem was, in my parent (library) project's build.config's sourceSets I've added the following:

jniLibs.srcDirs = ['jniLibs']
jni.srcDirs = []

This didn't work, .so files were missing from the child project's APK, so I've replaced it with:

jni.srcDirs = []
jniLibs.srcDir 'src/main/jniLibs'

With this method, everything is fine.

Melquiades
  • 8,496
  • 1
  • 31
  • 46
Szörényi Ádám
  • 1,223
  • 13
  • 17
  • 2
    Great answer. +1 To those who are using build-native.sh for your projects please note that once you have the .so files generated please copy the generated ABI .so files to src -> jniLibs. After that update gradle to jniLibs.srcDirs = ['src/jniLibs']. Else you will get unsatisfied link error when you download your git project in another location because .gitignore will usually have the modulelibs folder! Also do check-in the src/jniLibs to git so that the .so files are permanently available in repository, without having to build .so files every time you clone a new local repository. – Vadiraj Purohit May 17 '16 at 20:01