Android studio NDK Gradle build "Source ... and destination ... must be different"

Viewed 277

I'm using Android Studio with NDK, Gradle and CMake to build several shared libraries and link them together.

I keep getting the same error again and again in the build log:

:app:processDebugManifest [Passed]
:app:externalNativeBuildDebug [Passed]

Source C:\XXX\app\build\intermediates\cmake\debug\obj\arm64-v8a\libBGS-d.so and destination C:\XXX\app\build\intermediates\cmake\debug\obj\arm64-v8a\libBGS-d.so must be different

It's like gradle is trying to copy my library at the same position. The thing is, I have no idea where this instruction comes from and how I can debug it. There's really not much indication in the build log.

What's confusing is that is doesn't occur 100% of the time. Seems like there is a race condition somewhere. Also sometimes it's another library that triggers the build to fail. Also, cleaning the project doesn't help.

So here's my question: is there any place where I can get granular control over the Gradle build sequence ?

1 Answers

According to Dan Albert at https://stackoverflow.com/a/62223434/8068814 this appears to be a bug and he suggests cleaning the project, then triggering "refresh linked c++ projects" and then building the project. Since it is sometimes working for you, this might be a reliable solution in your case.

For me this did not help, but reverting the Gradle plugin to 3.6.2 was the only way for me to build my project.

Related