Wednesday, 30 January 2019

Android library project not using correct resources for debug variant

My problem is much as described in questions such as this: Build variants in Gradle for a Library Project in Android

That is, I'm making a library module with debug and release build types, and each build type has its own resources (for example in strings.xml). However, the release resources are always selected even when building the debug variant.

Pretty much everything I'm reading indicates that this has been fixed in Android Studio 3.0, but I'm on 3.3 and still experiencing the problem. One suggestion I've seen is to use releaseCompile and debugCompile. Those are deprecated so I used the replacements:

debugImplementation project(path: ':myLibrary', configuration: 'debug')
releaseImplementation project(path: ':myLibrary', configuration: 'release')

That produces these errors:

ERROR: Unable to resolve dependency for ':app@myAppDebug/compileClasspath': Could not resolve project :myLibrary.
Affected Modules: app

ERROR: Unable to resolve dependency for ':app@myAppDebugAndroidTest/compileClasspath': Could not resolve project :myLibrary.
Affected Modules: app

ERROR: Unable to resolve dependency for ':app@myAppDebugUnitTest/compileClasspath': Could not resolve project :myLibrary.
Affected Modules: app

I've quadruple checked the spelling, and it matches the name of the library. I was doing this before that resulted in the incorrect behavior described above:

implementation project(':myLibrary')

From the library build file:

android {
    publishNonDefault true
    ...
    buildTypes {
        debug {}
        release {
            minifyEnabled false
            zipAlignEnabled true
            signingConfig signingConfigs.releaseConfig
            //proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    ...

I also have a "qa" build type that I have omitted from discussion, but I have no reason to believe that's relevant as I'm not currently attempting to build that type. Any suggestions, or anything else I should add to the question?



from Android library project not using correct resources for debug variant

No comments:

Post a Comment