Reputation: 125
When adding the library async-http-client as a dependency on gradle, at the time of compile it gives an error.
build.gradle :
Any solution?
Upvotes: 0
Views: 539
Reputation: 7038
Disclaimer: I'm the dev of AsyncHttpClient
You won't be able to use AsyncHttpClient on Android. It uses JDK APIs that are only available in JDK8 (and some JDK7 APIs that were never introduced on Android, even in supposedly/claimed JDK7 compatible Android SDK, such as SSLParameters.html#setEndpointIdentificationAlgorithm).
This library is aimed at high performance non blocking IO for server to server communication and I only develop it as the underlying HTTP library for Gatling. Supporting Android is non goal as it conflicts too much.
IMO, Android is a broken ecosystem (fragmentation, JDK6 compat, non-compatibility with OpenJDK) and Android developers should use Android tailor-made libraries developed by people whose main interest is really Android. For an Android HTTP client, I would recommend Square's OkHttp.
Upvotes: 1
Reputation: 1169
This is because you are executing the app that uses java 1.8 but library may require 1.7
try this solution goto File->project Structure->app->(properties tab)change Source and Target Compability to 1.7
If it does not works then try to install jdk 1.7
Upvotes: 0
Reputation: 2323
Add this to build.gradle file of your defaultConfig
submodule and it should work.
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
Upvotes: 0
Reputation:
In your error screen I can see that.
If you are using the 'java' gradle plugin in a library submodule add targetCompatibility = '1.7' sourceCompatibility = '1.7' to that submodule's build.gradle file
If I don't get wrong gradle android plugin extends 'java' plugin, so you can just add these two lines in your "android" block in your build.gradle :
apply plugin: 'com.android.application'
android {
targetCompatibility = '1.7'
sourceCompatibility = '1.7'
...
}
Upvotes: 0