isabsent
isabsent

Reputation: 3763

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

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?

Upvotes: 7

Views: 15250

Answers (1)

ʍѳђઽ૯ท
ʍѳђઽ૯ท

Reputation: 16976

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.

Upvotes: 3

Related Questions