Есть в Android Studio проект, в нём есть модуль, у которого в Gradle прописано:
apply plugin: 'com.android.library'
android {
compileSdkVersion 19
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 11
targetSdkVersion 16
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'commons-io:commons-io:2.4'
}
Здесь происходит ошибка:
HttpURLConnection connection = (HttpURLConnection) fullUrl.openConnection();
connection.setUseCaches(false);
connection.setAllowUserInteraction(false);
// Set the request method.
connection.setRequestMethod(method);
// Add the session cookie.
connection.setRequestProperty("Cookie", "session=" + sessionKey);
connection.setRequestProperty("Accept-Encoding", "gzip, deflate");
if (method.equals("POST") && parameterString.length() > 0) {
connection.setRequestProperty("Content-Length", Integer.toString(parameterString.length()));
connection.addRequestProperty("Content-Type", "application/x-www-form-urlencoded");
connection.setRequestProperty("charset", "utf-8");
connection.getOutputStream().write(parameterString.getBytes("UTF8"));
}
connection.connect();
InputStream inputStream = connection.getInputStream();
// If the output was gzipped, change the input stream to the ungzipped version.
if ("gzip".equals(connection.getContentEncoding())) {
inputStream = new GZIPInputStream(inputStream);
}
String output = IOUtils.toString(inputStream, "UTF-8"); <---- ОШИБКА
inputStream.close();
Вот такая:
Если нужен конфиг Gradle основного модуля, вот он:
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.example.www"
minSdkVersion 11
targetSdkVersion 16
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:19.1.0'
compile 'com.android.support:appcompat-v7:20.0.0'
compile files('libs/android-async-http-1.4.6.jar')
compile files('libs/picasso-2.5.0.jar')
compile files('libs/tinylinegzip.jar')
compile 'com.laputapp:laputapp-pulltorefresh:2.1.1'
compile 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
}