I am trying okhttp and i have the next error:\
More than one file was found with OS independent path 'META-INF/proguard/okhttp3.pro'
This is what i have in my build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.woooba.login2"
minSdkVersion 23
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.squareup.okhttp3:okhttp:3.11.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
And this is the MainActivity.java
OkHttpClient client = new OkHttpClient();
String u = "https://samples.openweathermap.org/data/2.5/weather?q=London,uk&appid=b6907d289e10d714a6e88b30761fae22k";
task.execute(u);
Request request = new Request.Builder().url(u).build();
client.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
e.printStackTrace();
}
@Override
public void onResponse(Call call, Response response) throws IOException {
if (response.isSuccessful()){
Log.i("Response", response.body().string());
}
}
});
Anyone know what happen? It said ' More that one file was found' but not sure what it is talking about. I am new with android
Thanks
UPDATE proguard-rules.pro code displayed as per @vivek request
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
UPDATE 2 Adding to build.grade within android{} the next: link
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/license.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
exclude 'META-INF/proguard/okhttp3.pro'
}
Pressed "Sync now" and play and the error's gone but when you go to 4:run I see another error.
More than one file was found with OS independent path 'okhttp3/internal/publicsuffix/publicsuffixes.gz'
So i added to packagingOptions{}
exclude 'okhttp3/internal/publicsuffix/publicsuffixes.gz'
and I get the next error
Compilation failed to complete
Android issues:
Program type already present: okhttp3.Call$Factory Message{kind=ERROR, text=Program type already present: okhttp3.Call$Factory, sources=[Unknown source file], tool name=Optional.of(D8)}
Any idea? i've seen here that suggest to remove the implementation of okhttp3 but come up erros when I call this class in MainActivity
OkHttpClient client = new OkHttpClient();