'Why does gradle task assembleRelease need to be run twice to generate a new aar

I am building a library project. Its build.gralde has the following:

android {
    compileSdkVersion versionCompiler

    compileOptions {
        sourceCompatibility javaSourceCompatibility
        targetCompatibility javaTargetCompatibility
    }

    defaultConfig {
        minSdkVersion 23
        targetSdkVersion versionTarget
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
    sourceSets {
        main {
            jniLibs.srcDir 'src/main/libs'
        }
    }
}

After I make some changes to a CPP source file, I run assembleRelease and keep an eye on folder build\outputs\aar. The aar file does not change at all after assembleRelease is finished. Then, I run assembleRelease again, and the aar file changes. This is 100% repeatable.

Could anyone shed some light on this?

Android Studio Bumblebee | 2021.1.1 Patch 3
Build #AI-211.7628.21.2111.8309675, built on March 16, 2022
Runtime version: 11.0.11+9-b60-7590822 amd64
VM: OpenJDK 64-Bit Server VM by Oracle Corporation
Windows 10 10.0
GC: G1 Young Generation, G1 Old Generation
Memory: 4096M
Cores: 16
Registry: external.system.auto.import.disabled=true, debugger.watches.in.variables=false
Non-Bundled Plugins: com.intellij.marketplace (211.7628.36), com.thoughtworks.gauge (211.6693.111), org.jetbrains.kotlin (211-1.6.21-release-334-AS7442.40), com.android.aas (3.6.0), com.google.mad-scorecard (1.2), org.intellij.plugins.markdown (211.7142.37)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source