I'm trying to generate a signed apk but I've got the following 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
}
}
...
So I started looking at how to fix the problem and hit the head against this question and I've found some useful information.
In practice, there is a file located in ..\app\build\reports\
named \lint-results-release-fatal.html
containing the reason for the error:
Duplicate Platform Classes
../../build.gradle: commons-logging defines classes that conflict with classes now provided by Android. Solutions include finding newer versions or alternative libraries that don't have the same problem (for example, for httpclient use HttpUrlConnection or `okhttp` instead), or repackaging the library using something like jarjar.
../../build.gradle: `httpclient` defines classes that conflict with classes now provided by Android. Solutions include finding newer versions or alternative libraries that don't have the same problem (for example, for `httpclient` use HttpUrlConnection or `okhttp` instead), or repackaging the library using something like jarjar.
Sorry if the reading can be boring but I'm trying to explain step by step...
So I kept looking until I got stuck following this question. Basically the advice is to add these two lines of code to exclude duplicate classes:
configurations {
all {
exclude module: 'httpclient'
exclude module: 'commons-logging'
}
}
Unfortunately, there is a problem, when I go to compile the app again I get this error that I can't solve:
error: cannot access ContentType
class file for org.apache.http.entity.ContentType not found
I really think that the exclusion of the httpclient module and the error reported above are linked, but I could be wrong...
These are some useful information:
Android Studio 3.5.1
Build #AI-191.8026.42.35.5900203, built on September 25, 2019
JRE: 1.8.0_202-release-1483-b03 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0
Thanks again for reading up to here and if you have a solution or a suggestion are welcome!
14:54 05/11/19
Add other information that may give you a better overview of the situation
compileSdkVersion 28
defaultConfig {
applicationId "com.example.app"
minSdkVersion 22
targetSdkVersion 28
versionCode 2
versionName "21.19.08.27"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
16:35 05/11/2019
Here there are the dependencies
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.recyclerview:recyclerview-selection:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.1.0-alpha07'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.williamww:silky-signature:0.1.0'
implementation 'com.afollestad.material-dialogs:core:0.9.1.0'
implementation 'com.weiwangcn.betterspinner:library-material:1.1.0'
implementation 'com.weiwangcn.betterspinner:library:1.1.0'
implementation 'org.apache.httpcomponents:httpmime:4.3.6'
implementation 'com.ajts.androidmads.sqliteimpex:library:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
10:14 08/11/2019
Previusly i didn't mention the utilize of useLibrary 'org.apache.http.legacy'
10:22 11/11/2019
I've created a replica of the error i'm getting on the following github project.
So my goal is to be able to compile and use the following classes:
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.mime.MultipartEntity;
import org.apache.http.entity.mime.content.InputStreamBody;
import org.apache.http.entity.mime.content.StringBody;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.BasicHttpParams;