Faced an error regarding implicit task dependency while building an android app in android studio

553 Views Asked by At

Recently I created a new android app containing native c++ libraries.

I used gradle-8.0, AGP-7.4.2, JDK-11 and C++14.

The app has a module dependency which contains native c++ code. This module has a dependency on a remote AAR file that is download from our own maven repository. After downloading AAR the jni folder is extracted into some folder that contains 4 ABIs and an .so file in it. I then link it to this module in the CMakeLists.txt

The issue is, I encounter an error while building my app using gradle wrapper saying,

***************** ERROR OUTPUT START ***********************

FAILURE: Build failed with an exception.

* What went wrong:
A problem was found with the configuration of task ':app:externalNativeBuildPqrDebug' (type 'ExternalNativeBuildTask').
  - Gradle detected a problem with the following location: '<private>/AndroidStudioProjects/SFIOTestApp/app/build/intermediates/cxx/Debug/1y181390'.
    
    Reason: Task ':app:mergeNonpqrDebugNativeLibs' uses this output of task ':app:externalNativeBuildPqrDebug' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
    
    Possible solutions:
      1. Declare task ':app:externalNativeBuildPqrDebug' as an input of ':app:mergeNonpqrDebugNativeLibs'.
      2. Declare an explicit dependency on ':app:externalNativeBuildPqrDebug' from ':app:mergeNonpqrDebugNativeLibs' using Task#dependsOn.
      3. Declare an explicit dependency on ':app:externalNativeBuildPqrDebug' from ':app:mergeNonpqrDebugNativeLibs' using Task#mustRunAfter.
    
    Please refer to https://docs.gradle.org/8.0/userguide/validation_problems.html#implicit_dependency for more details about this problem.

***************** ERROR OUTPUT END ***********************

:app:externalNativeBuildPqrDebug and :app:mergeNonpqrDebugNativeLibs are implicit tasks. I have not defined them. Pqr and Nonpqr are the build flavours I have created. Debug is the build type I used.

Build command I used : ./gradlew :app:assembleDebug

I don't encounter this error while using gradle-6.5 and AGP-4.1.1.

I tried reading the documentation of Android Gradle Plugin but didn't find any clue. I tried creating implicit tasks and make it depended (dependsOn and mustRunAfter) but this also didn't work.

0

There are 0 best solutions below