Closed JiriHoffmann closed 2 years ago
Thanks for the PR. The issue with REACT_NATIVE_JNI_LIB
is known. It happens because we have to copy over all RN aar file before compiling c++ code. But for some reason the copying function in gradle build does not get called. Probably because different versions of gradle work differently. Here is how I have fixed the problem:
def extracted = false;
task extractJNIFiles {
if (extracted) return
doLast {
configurations.extractJNI.files.each {
def file = it.absoluteFile
copy {
from zipTree(file)
into "$buildDir/$file.name"
include "jni/**/*"
}
extracted = true;
}
}
}
// Attach extraction function tasks to all tasks
tasks.whenTaskAdded { task ->
task.dependsOn(extractJNIFiles);
}
As soon as gradle build starts, it makes all the task depend on extractJNIFiles
function. Then later, once files are extracted, we set extracted:true
after which we ignore all calls made to extractJNIFiles
by other tasks.
I included that code in the PR, but the issue is still there
@JiriHoffmann I think this is a seperate problem. I will look into it again. It has been working on my library but i guess it isn't 100% perfect. Maybe we should read gradle docs to see how to run a task before all other tasks so we are sure rn aar is there always.
Note that there is a weird quirk I have not been able to figure out. While building the example on Android I kept running into issues with REACT_NATIVE_JNI_LIB in android/CMakeLists.txt not being found. Simply logging the
LIBRN_DIR
variable withmessage()
seems to fix the issue. Also, this happens only during the first build. So even if themessage()
is removed after the first successful build, it will keep working. For now, I just left it there.Closes #11