Home > Software engineering >  :minifyReleaseWithR8 fails for library modules with no property value available
:minifyReleaseWithR8 fails for library modules with no property value available

Time:06-09

I'm unable to find the cause of the error:

Could not determine the dependencies of task ':analytics:minifyReleaseWithR8'.
> Cannot query the value of this property because it has no value available.

My configuration:

Gradle convention file named android-library.gradle.kts applied to all library modules:

    defaultConfig {
        targetSdk = 32
        consumerProguardFile("consumer-rules.pro")
    }
    
    compileSdk = 32

    defaultConfig {
        minSdk = 26
        testInstrumentationRunner = Config.testRunner
        resourceConfigurations.addAll(Config.supportedLocales)
    }

    buildTypes {
        getByName("release") {
            isMinifyEnabled = true
            ndk.debugSymbolLevel = Config.debugSymbolLevel
        }
        getByName("debug") {
            isMinifyEnabled = false
            ndk.debugSymbolLevel = Config.debugSymbolLevel
        }
    }

(These are actually merged with an extension function that I use to configure android modules, hence two times the Config{} block, same for app module below)

App module

defaultConfig {
        applicationId = Config.applicationId
        targetSdk = 32
        versionCode = Config.versionCode
        versionName = Config.versionName

        proguardFiles(
            getDefaultProguardFile("proguard-android-optimize.txt"),
            "proguard-rules.pro",
        )
    }
    buildTypes {
        debug {
            signingConfig = signingConfigs.getByName("debug")
            versionNameSuffix = "-debug"
            isShrinkResources = false
        }
        release {
            isShrinkResources = true
            signingConfig = signingConfigs.getByName("release")
        }
    }

Context:

  1. The issue happens only on release build
  2. The sync process completes normally
  3. Build process crashes immediately at the moment of starting to build the first included library module, far before the :minifyReleaseWithR8 step
  4. Disabling proguard for library modules works, enabling back - nope
  5. Reproduces always
  6. I have mac M1 as my main machine
  7. I couldn't trace the issue back to exact file change, or I would've solved it already, but it started at some point while there were significant dependency upgrades being made

I've tried:

  1. Disabling minify on release library module builds. It helped, but now my library modules aren't obfuscated, which is not an acceptable solution
  2. Removing, adding and changing the proguardFiles() block of library modules and app module to contain, not contain, and contain different entries. No avail, unless minify is enabled, it doesn't work.
  3. Deleting, installing, reinstalling my buildTools and other SDK dependencies, no result. I've tried all api Tiramisu, 32, 31, and 30 build tools variations.
  4. Creating/deleting/clearing/moving proguard-rules.pro and consumer-rules.pro of all of my modules. Doesn't change anything at all.
  5. Debugging the gradle task, but after 6 hours, I couldn't find the name of the file or whatever mysterious "provider" it can't find. Closest I've come is some other task dependency that is not being executed, although that is just a guess.
  6. Of course, clearing caches, directories, rebooting, gradle clean and other conventional tricks.
  7. Everything listed under this question

UPD: Using debugger, I identified that the problem lies in the property property(org.gradle.api.file.RegularFile, property(org.gradle.api.file.RegularFile, property(org.gradle.api.file.RegularFile, undefined))) I have no idea what that means unfortunately.

CodePudding user response:

After all this time, I've found the problem:

My gradle library plugin had this block:

    buildFeatures {
        buildConfig = false
        androidResources = false // the culprit
    }

It's not documented, and I added it accidentally.
It looks completely unrelated to R8 and from the documentation, it isn't clear what it does exactly.
The docstring says "TBD" which isn't really helpful
Setting the flag to true fixed the build.

  • Related