Lint found fatal errors while assembling a release target - gradle error?

15,172

the release apk is compiled without any error messages. Is it a some gradle bug or what!?

It seems like that dependency has a package which conflicts with the Android itself. The reason why it works without implementation and adding it manually, it might be that it downloads needed packages when you add it to be downloaded from maven repository and that's when the issue came up.

Anyways, the solution at these situations might be using the latest version:

implementation 'commons-validator:commons-validator:1.6'

Or, exclude it as follows:

implementation ('commons-validator:commons-validator:1.5.0') {
        exclude group: 'commons-logging', module: 'commons-logging'
    }

Note: The following part can't be helpful (for this issue) since the error says:

Commons-logging defines classes that conflict with classes now provided by Android

You could go deeply by running ./gradlew app:dependencies in the IDE terminal to see which one conflicts with the Android itself and then excluding it as above.

Share:
15,172
isabsent
Author by

isabsent

Updated on June 04, 2022

Comments

  • isabsent
    isabsent almost 2 years

    I am using AS 3.1 with gradle-4.5-all.zip and main build.gradle:

    buildscript {
        repositories {
            jcenter()
            google()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.1.3'
        }
    }
    
    allprojects {
        repositories {
            jcenter()
            google()
        }
    }
    

    An app-level build.gradle looks like following:

    apply plugin: 'com.android.application'
    
    android {
        compileSdkVersion 27
        buildToolsVersion "27.0.3"
        useLibrary 'org.apache.http.legacy'
    
        defaultConfig {
            applicationId "com.example"
            minSdkVersion 14
            targetSdkVersion 27
            versionCode 6
            versionName "1.00"
        }
    
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
            }
        }
    }
    
    dependencies {
        implementation 'ch.acra:acra:4.6.1'
        implementation 'commons-validator:commons-validator:1.5.0'
        implementation 'com.android.support:support-v13:27.1.1'
        implementation 'com.google.code.gson:gson:2.8.0'
        implementation 'com.nineoldandroids:library:2.4.0'
        implementation 'com.google.zxing:core:3.3.0'
    }
    

    and works fine when I set up a debug version under AS 3.1 to my phone, but when I try to make release apk it shows me an error:

    Lint found fatal errors while assembling a release target.
    
    To proceed, either fix the issues identified by lint, or modify your build 
    script as follows:
    ...
    android {
        lintOptions {
            checkReleaseBuilds false
            // Or, if you prefer, you can continue to check for errors in release builds,
            // but continue the build even when errors are found:
            abortOnError false
        }
    }
    

    As I can see in the lint-results-release-fatal.html the reason is:

    lint-results-release-fatal.html

    I would not like to change lintOptions to supress this error because it doesn't solve the problem, it just hide it. More over, when I use

    implementation files('libs/commons-validator-1.5.0.jar')
    

    instead of

    implementation 'commons-validator:commons-validator:1.5.0'
    

    the release apk is compiled without any error messages. Is it a some gradle bug or what!?

    P.S. I have attached a file androidDependencies.txt. Package commons-logging doesn't appears in the dependencies at all! How is it possible to get the solution of above problem analysing this file?

  • isabsent
    isabsent over 5 years
    Changing to 1.6 doesn't work. I have tried this before asking the question. But your second assumption works fine!
  • isabsent
    isabsent over 5 years
    I have attached a file androidDependencies.txt to my question. Would you be so kind to show how is it possible to get your solution analysing this file?
  • ʍѳђઽ૯ท
    ʍѳђઽ૯ท over 5 years
    Check the error : Commons-logging defines classes that conflict with classes now provided by Android. commons-logging is the point here which is provided in the Android itself and not in the Android Studio project. So, we probably can't see it in there. I'm gonna delete that part since it comes from Android itself. Thanks for mentioning.